Package com.ibm.icu.impl

Examples of com.ibm.icu.impl.IntTrie


                }
                ++ start;
            }
        }
   
        IntTrie trie = newTrie.serialize(new _testFoldedValue(newTrie),
                                         new _testFoldingOffset());
   
        // test linear Latin-1 range from utrie_getData()
        if (latin1Linear) {
            start = 0;
            for (int i = 0; i < countCheckRanges && start <= 0xff; ++ i) {
                int limit = checkRanges[i].limit;
                int value = checkRanges[i].value;
   
                while (start < limit && start <= 0xff) {
                    if (value != trie.getLatin1LinearValue((char)start)) {
                        errln("IntTrie.getLatin1LinearValue[U+"
                              + Integer.toHexString(start) + "]==0x"
                              + Integer.toHexString(
                                        trie.getLatin1LinearValue((char) start))
                              + " instead of 0x" + Integer.toHexString(value));
                    }
                    ++ start;
                }
            }
        }
   
        if (latin1Linear != trie.isLatin1Linear()) {
            errln("trie serialization did not preserve "
                  + "Latin-1-linearity");
        }
   
        // verify that all these values are in the serialized Trie
        start = 0;
        for (int i = 0; i < countCheckRanges; ++ i) {
            int limit = checkRanges[i].limit;
            int value = checkRanges[i].value;
   
            if (start == 0xd800) {
                // skip surrogates
                start = limit;
                continue;
            }
   
            while (start < limit) {
                if (start <= 0xffff) {
                    int value2 = trie.getBMPValue((char)start);
                    if (value != value2) {
                        errln("serialized trie.getBMPValue(U+"
                              + Integer.toHexString(start) + " == 0x"
                              + Integer.toHexString(value2) + " instead of 0x"
                              + Integer.toHexString(value));
                    }
                    if (!UTF16.isLeadSurrogate((char)start)) {
                        value2 = trie.getLeadValue((char)start);
                        if (value != value2) {
                            errln("serialized trie.getLeadValue(U+"
                              + Integer.toHexString(start) + " == 0x"
                              + Integer.toHexString(value2) + " instead of 0x"
                              + Integer.toHexString(value));
                        }
                    }
                }
                int value2 = trie.getCodePointValue(start);
                if (value != value2) {
                    errln("serialized trie.getCodePointValue(U+"
                          + Integer.toHexString(start) + ")==0x"
                          + Integer.toHexString(value2) + " instead of 0x"
                          + Integer.toHexString(value));
                }
                ++ start;
            }
        }
   
        // enumerate and verify all ranges
       
        int enumRanges = 1;
        TrieIterator iter  = new _testEnumValue(trie);
        RangeValueIterator.Element result = new RangeValueIterator.Element();
        while (iter.next(result)) {
            if (result.start != checkRanges[enumRanges -1].limit
                || result.limit != checkRanges[enumRanges].limit
                || (result.value ^ 0x5555) != checkRanges[enumRanges].value) {
                errln("utrie_enum() delivers wrong range [U+"
                      + Integer.toHexString(result.start) + "..U+"
                      + Integer.toHexString(result.limit) + "].0x"
                      + Integer.toHexString(result.value ^ 0x5555)
                      + " instead of [U+"
                      + Integer.toHexString(checkRanges[enumRanges -1].limit)
                      + "..U+"
                      + Integer.toHexString(checkRanges[enumRanges].limit)
                      + "].0x"
                      + Integer.toHexString(checkRanges[enumRanges].value));
            }
            enumRanges ++;
        }
   
        // test linear Latin-1 range
        if (trie.isLatin1Linear()) {
            for (start = 0; start < 0x100; ++ start) {
                if (trie.getLatin1LinearValue((char)start)
                    != trie.getLeadValue((char)start)) {
                    errln("trie.getLatin1LinearValue[U+"
                          + Integer.toHexString(start) + "]=0x"
                          + Integer.toHexString(
                                        trie.getLatin1LinearValue((char)start))
                          + " instead of 0x"
                          + Integer.toHexString(
                                        trie.getLeadValue((char)start)));
                }
            }
        }
   
        _testTrieIteration(trie, checkRanges, countCheckRanges);
View Full Code Here


            }
        }
    }

    public void TestDummyIntTrie() {
        IntTrie trie;
        final int initialValue=0x01234567, leadUnitValue=0x89abcdef;
        int value;
        int c;
        trie=new IntTrie(initialValue, leadUnitValue, new DummyGetFoldingOffset());

        /* test that all code points have initialValue */
        for(c=0; c<=0x10ffff; ++c) {
            value=trie.getCodePointValue(c);
            if(value!=initialValue) {
                errln("IntTrie/dummy.getCodePointValue(c)(U+"+hex(c)+")=0x"+hex(value)+" instead of 0x"+hex(initialValue));
            }
        }

        /* test that the lead surrogate code units have leadUnitValue */
        for(c=0xd800; c<=0xdbff; ++c) {
            value=trie.getLeadValue((char)c);
            if(value!=leadUnitValue) {
                errln("IntTrie/dummy.getLeadValue(c)(U+"+hex(c)+")=0x"+hex(value)+" instead of 0x"+hex(leadUnitValue));
            }
        }
    }
View Full Code Here

            for (int i = 0; i < m_contractionCESize_; i ++) {
                rbc.m_contractionCE_[i] = m_dataInputStream_.readInt();
            }
            readcount += (m_contractionCESize_ << 2);
        }
        rbc.m_trie_ = new IntTrie(m_dataInputStream_,
                                 RuleBasedCollator.DataManipulate.getInstance());
        if (!rbc.m_trie_.isLatin1Linear()) {
            throw new IOException("Data corrupted, "
                                  + "Collator Tries expected to have linear "
                                  + "latin one data arrays");
View Full Code Here

            for (int i = 0; i < m_contractionCESize_; i ++) {
                rbc.m_contractionCE_[i] = m_dataInputStream_.readInt();
            }
            readcount += (m_contractionCESize_ << 2);
        }
        rbc.m_trie_ = new IntTrie(m_dataInputStream_,
                                 RuleBasedCollator.DataManipulate.getInstance());
        if (!rbc.m_trie_.isLatin1Linear()) {
            throw new IOException("Data corrupted, "
                                  + "Collator Tries expected to have linear "
                                  + "latin one data arrays");
View Full Code Here

            for (int i = 0; i < m_contractionCESize_; i ++) {
                rbc.m_contractionCE_[i] = m_dataInputStream_.readInt();
            }
            readcount += (m_contractionCESize_ << 2);
        }
        rbc.m_trie_ = new IntTrie(m_dataInputStream_,
                                 RuleBasedCollator.DataManipulate.getInstance());
        if (!rbc.m_trie_.isLatin1Linear()) {
            throw new IOException("Data corrupted, "
                                  + "Collator Tries expected to have linear "
                                  + "latin one data arrays");
View Full Code Here

            for (int i = 0; i < m_contractionCESize_; i++) {
                rbc.m_contractionCE_[i] = m_dataInputStream_.readInt();
            }
            readcount += (m_contractionCESize_ << 2);
        }
        rbc.m_trie_ = new IntTrie(m_dataInputStream_, RuleBasedCollator.DataManipulate.getInstance());
        if (!rbc.m_trie_.isLatin1Linear()) {
            throw new IOException("Data corrupted, " + "Collator Tries expected to have linear "
                    + "latin one data arrays");
        }
        readcount += rbc.m_trie_.getSerializedDataSize();
View Full Code Here

            for (int i = 0; i < m_contractionCESize_; i ++) {
                rbc.m_contractionCE_[i] = m_dataInputStream_.readInt();
            }
            readcount += (m_contractionCESize_ << 2);
        }
        rbc.m_trie_ = new IntTrie(m_dataInputStream_,
                                 RuleBasedCollator.DataManipulate.getInstance());
        if (!rbc.m_trie_.isLatin1Linear()) {
            throw new IOException("Data corrupted, "
                                  + "Collator Tries expected to have linear "
                                  + "latin one data arrays");
View Full Code Here

TOP

Related Classes of com.ibm.icu.impl.IntTrie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.