// Ensure that ceratain properties were generated correctly. func TestTable(t *testing.T) { tests := []tableTest{ tableTest{ rangetable.Merge( unicode.Lt, unicode.Nl, unicode.No, // Other letter digits unicode.Me, // Modifiers unicode.Zs, // Spaces unicode.So, // Symbols unicode.Pi, unicode.Pf, // Punctuation ), idDisOrFreePVal, }, tableTest{ rangetable.New(0x30000, 0x30101, 0xDFFFF), unassigned, }, } assigned := rangetable.Assigned(UnicodeVersion) for _, test := range tests { rangetable.Visit(test.rangeTable, func(r rune) { if !unicode.In(r, assigned) { return } b := make([]byte, 4) n := utf8.EncodeRune(b, r) trieval, _ := dpTrie.lookup(b[:n]) p := entry(trieval).property() if p != test.prop && !exceptions.Contains(r) { t.Errorf("%U: got %+x; want %+x", r, test.prop, p) } }) } }
// These tables are hand-extracted from: // http://www.unicode.org/Public/8.0.0/ucd/extracted/DerivedBidiClass.txt func visitDefaults(fn func(r rune, c Class)) { // first write default values for ranges listed above. visitRunes(fn, AL, []rune{ 0x0600, 0x07BF, // Arabic 0x08A0, 0x08FF, // Arabic Extended-A 0xFB50, 0xFDCF, // Arabic Presentation Forms 0xFDF0, 0xFDFF, 0xFE70, 0xFEFF, 0x0001EE00, 0x0001EEFF, // Arabic Mathematical Alpha Symbols }) visitRunes(fn, R, []rune{ 0x0590, 0x05FF, // Hebrew 0x07C0, 0x089F, // Nko et al. 0xFB1D, 0xFB4F, 0x00010800, 0x00010FFF, // Cypriot Syllabary et. al. 0x0001E800, 0x0001EDFF, 0x0001EF00, 0x0001EFFF, }) visitRunes(fn, ET, []rune{ // European Terminator 0x20A0, 0x20Cf, // Currency symbols }) rangetable.Visit(unicode.Noncharacter_Code_Point, func(r rune) { fn(r, BN) // Boundary Neutral }) ucd.Parse(gen.OpenUCDFile("DerivedCoreProperties.txt"), func(p *ucd.Parser) { if p.String(1) == "Default_Ignorable_Code_Point" { fn(p.Rune(0), BN) // Boundary Neutral } }) }
func (tt *tableTest) run(t *testing.T) { rangetable.Visit(tt.rangeTable, func(r rune) { b := make([]byte, 4) n := utf8.EncodeRune(b, r) trieval, _ := dpTrie.lookup(b[:n]) p := property(trieval) if p != tt.prop && !exceptions.Contains(r) { t.Fail() } }) }