diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2019-01-18 16:45:30 +0100 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2019-01-24 02:11:08 +0100 |
commit | ce354a6afbf1813c9a5565a00f6937c1b6fd1e42 (patch) | |
tree | 5f8fef7e2879a8aec6e8c22302c4fce5e46e7083 /vendor/golang.org/x/text/unicode/norm/example_iter_test.go | |
parent | 56dd0f4dfdc33594502ec02421425c3432570be3 (diff) |
[pkg] remove vendoring of golang/x/*
I think there's no need of vendoring this.
The debian package builds fine without them - at least with the text-dev
package in testing.
Diffstat (limited to 'vendor/golang.org/x/text/unicode/norm/example_iter_test.go')
-rw-r--r-- | vendor/golang.org/x/text/unicode/norm/example_iter_test.go | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/vendor/golang.org/x/text/unicode/norm/example_iter_test.go b/vendor/golang.org/x/text/unicode/norm/example_iter_test.go deleted file mode 100644 index 998d896..0000000 --- a/vendor/golang.org/x/text/unicode/norm/example_iter_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2012 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 norm_test - -import ( - "bytes" - "fmt" - "io" - "unicode/utf8" - - "golang.org/x/text/unicode/norm" -) - -// EqualSimple uses a norm.Iter to compare two non-normalized -// strings for equivalence. -func EqualSimple(a, b string) bool { - var ia, ib norm.Iter - ia.InitString(norm.NFKD, a) - ib.InitString(norm.NFKD, b) - for !ia.Done() && !ib.Done() { - if !bytes.Equal(ia.Next(), ib.Next()) { - return false - } - } - return ia.Done() && ib.Done() -} - -// FindPrefix finds the longest common prefix of ASCII characters -// of a and b. -func FindPrefix(a, b string) int { - i := 0 - for ; i < len(a) && i < len(b) && a[i] < utf8.RuneSelf && a[i] == b[i]; i++ { - } - return i -} - -// EqualOpt is like EqualSimple, but optimizes the special -// case for ASCII characters. -func EqualOpt(a, b string) bool { - n := FindPrefix(a, b) - a, b = a[n:], b[n:] - var ia, ib norm.Iter - ia.InitString(norm.NFKD, a) - ib.InitString(norm.NFKD, b) - for !ia.Done() && !ib.Done() { - if !bytes.Equal(ia.Next(), ib.Next()) { - return false - } - if n := int64(FindPrefix(a[ia.Pos():], b[ib.Pos():])); n != 0 { - ia.Seek(n, io.SeekCurrent) - ib.Seek(n, io.SeekCurrent) - } - } - return ia.Done() && ib.Done() -} - -var compareTests = []struct{ a, b string }{ - {"aaa", "aaa"}, - {"aaa", "aab"}, - {"a\u0300a", "\u00E0a"}, - {"a\u0300\u0320b", "a\u0320\u0300b"}, - {"\u1E0A\u0323", "\x44\u0323\u0307"}, - // A character that decomposes into multiple segments - // spans several iterations. - {"\u3304", "\u30A4\u30CB\u30F3\u30AF\u3099"}, -} - -func ExampleIter() { - for i, t := range compareTests { - r0 := EqualSimple(t.a, t.b) - r1 := EqualOpt(t.a, t.b) - fmt.Printf("%d: %v %v\n", i, r0, r1) - } - // Output: - // 0: true true - // 1: false false - // 2: true true - // 3: true true - // 4: true true - // 5: true true -} |