# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 require 'spec_helper' include TwitterCldr::Collation describe TrieBuilder do describe '.load_default_trie' do let(:trie) { TrieBuilder.load_default_trie } before(:each) { mock_default_table } it 'returns a Trie' do expect(trie).to be_instance_of(Trie) end it 'adds every collation element from the fractional collation elements table to the trie' do collation_elements_table.each do |code_points, collation_elements| expect(trie.get(code_points)).to eq(collation_elements) end end let(:fractional_uca_short_stub) do < Reordering Tokens [top_byte 00 TERMINATOR ] # [0] TERMINATOR=1 [top_byte 01 LEVEL-SEPARATOR ] # [0] LEVEL-SEPARATOR=1 [top_byte 02 FIELD-SEPARATOR ] # [0] FIELD-SEPARATOR=1 [top_byte 03 SPACE ] # [9] SPACE=1 Cc=6 Zl=1 Zp=1 Zs=1 # VALUES BASED ON UCA [first tertiary ignorable [,,]] # CONSTRUCTED [last tertiary ignorable [,,]] # CONSTRUCTED # Warning: Case bits are masked in the following [first tertiary in secondary non-ignorable [X, X, 05]] # U+0332 COMBINING LOW LINE [last tertiary in secondary non-ignorable [X, X, 3D]] # U+2A74 DOUBLE COLON EQUAL END end let(:collation_elements_table) do [ # 0000; [,,] [[0], [[0, 0, 0]]], # 030C; [, 97, 05] [[780], [[0, 151, 5]]], # 215E; [20, 05, 3B][0D 75 2C, 05, 3B][22, 05, 3D] [[8542], [[32, 5, 59], [881964, 5, 59], [34, 5, 61]]], # FC63; [, D3 A9, 33][, D5 11, 33] [[64611], [[0, 54185, 51], [0, 54545, 51]]], # 0E40 0E01; [72 0A, 05, 05][72 7E, 05, 3D] [[3648, 3585], [[29194, 5, 5], [29310, 5, 61]]], # 0E40 0E02; [72 0C, 05, 05][72 7E, 05, 3D] [[3648, 3586], [[29196, 5, 5], [29310, 5, 61]]], # FDD0 0063; [, 97, 3D] [[64976, 99], [[0, 151, 61]]], # FDD0 0064; [, A7, 09] [[64976, 100], [[0, 167, 9]]], # FFFE; [02, 02, 02] [[65534], [[2, 2, 2]]], # FFFF; [EF FE, 05, 05] [[65535], [[61438, 5, 5]]] ] end end let(:tailoring_resource_stub) do <