// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bidi import ( "flag" "fmt" "log" "strconv" "strings" "testing" "golang.org/x/text/internal/gen" "golang.org/x/text/internal/testtext" "golang.org/x/text/internal/ucd" "golang.org/x/text/unicode/norm" ) var testLevels = flag.Bool("levels", false, "enable testing of levels") // TestBidiCore performs the tests in BidiTest.txt. // See http://www.unicode.org/Public/UCD/latest/ucd/BidiTest.txt. func TestBidiCore(t *testing.T) { testtext.SkipIfNotLong(t) r := gen.OpenUCDFile("BidiTest.txt") defer r.Close() var wantLevels, wantOrder []string p := ucd.New(r, ucd.Part(func(p *ucd.Parser) { s := strings.Split(p.String(0), ":") switch s[0] { case "Levels": wantLevels = strings.Fields(s[1]) case "Reorder": wantOrder = strings.Fields(s[1]) default: log.Fatalf("Unknown part %q.", s[0]) } })) for p.Next() { types := []Class{} for _, s := range p.Strings(0) { types = append(types, bidiClass[s]) } // We ignore the bracketing part of the algorithm. pairTypes := make([]bracketType, len(types)) pairValues := make([]rune, len(types)) for i := uint(0); i < 3; i++ { if p.Uint(1)&(1<