mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
bytes: add EqualFold
R=golang-dev, r, r CC=golang-dev https://golang.org/cl/5123047
This commit is contained in:
parent
4bdf1fc02b
commit
c68ae9d467
3 changed files with 85 additions and 1 deletions
|
|
@ -862,3 +862,31 @@ func TestTitle(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
var EqualFoldTests = []struct {
|
||||
s, t string
|
||||
out bool
|
||||
}{
|
||||
{"abc", "abc", true},
|
||||
{"ABcd", "ABcd", true},
|
||||
{"123abc", "123ABC", true},
|
||||
{"αβδ", "ΑΒΔ", true},
|
||||
{"abc", "xyz", false},
|
||||
{"abc", "XYZ", false},
|
||||
{"abcdefghijk", "abcdefghijX", false},
|
||||
{"abcdefghijk", "abcdefghij\u212A", true},
|
||||
{"abcdefghijK", "abcdefghij\u212A", true},
|
||||
{"abcdefghijkz", "abcdefghij\u212Ay", false},
|
||||
{"abcdefghijKz", "abcdefghij\u212Ay", false},
|
||||
}
|
||||
|
||||
func TestEqualFold(t *testing.T) {
|
||||
for _, tt := range EqualFoldTests {
|
||||
if out := EqualFold([]byte(tt.s), []byte(tt.t)); out != tt.out {
|
||||
t.Errorf("EqualFold(%#q, %#q) = %v, want %v", tt.s, tt.t, out, tt.out)
|
||||
}
|
||||
if out := EqualFold([]byte(tt.t), []byte(tt.s)); out != tt.out {
|
||||
t.Errorf("EqualFold(%#q, %#q) = %v, want %v", tt.t, tt.s, out, tt.out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue