| 1 |
// Copyright 2013 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
//go:build !goexperiment.jsonv2 |
| 6 |
|
| 7 |
package json |
| 8 |
|
| 9 |
import ( |
| 10 |
"bytes" |
| 11 |
"testing" |
| 12 |
) |
| 13 |
|
| 14 |
func FuzzEqualFold(f *testing.F) { |
| 15 |
for _, ss := range [][2]string{ |
| 16 |
{"", ""}, |
| 17 |
{"123abc", "123ABC"}, |
| 18 |
{"αβδ", "ΑΒΔ"}, |
| 19 |
{"abc", "xyz"}, |
| 20 |
{"abc", "XYZ"}, |
| 21 |
{"1", "2"}, |
| 22 |
{"hello, world!", "hello, world!"}, |
| 23 |
{"hello, world!", "Hello, World!"}, |
| 24 |
{"hello, world!", "HELLO, WORLD!"}, |
| 25 |
{"hello, world!", "jello, world!"}, |
| 26 |
{"γειά, κόσμε!", "γειά, κόσμε!"}, |
| 27 |
{"γειά, κόσμε!", "Γειά, Κόσμε!"}, |
| 28 |
{"γειά, κόσμε!", "ΓΕΙΆ, ΚΌΣΜΕ!"}, |
| 29 |
{"γειά, κόσμε!", "ΛΕΙΆ, ΚΌΣΜΕ!"}, |
| 30 |
{"AESKey", "aesKey"}, |
| 31 |
{"AESKEY", "aes_key"}, |
| 32 |
{"aes_key", "AES_KEY"}, |
| 33 |
{"AES_KEY", "aes-key"}, |
| 34 |
{"aes-key", "AES-KEY"}, |
| 35 |
{"AES-KEY", "aesKey"}, |
| 36 |
{"aesKey", "AesKey"}, |
| 37 |
{"AesKey", "AESKey"}, |
| 38 |
{"AESKey", "aeskey"}, |
| 39 |
{"DESKey", "aeskey"}, |
| 40 |
{"AES Key", "aeskey"}, |
| 41 |
} { |
| 42 |
f.Add([]byte(ss[0]), []byte(ss[1])) |
| 43 |
} |
| 44 |
equalFold := func(x, y []byte) bool { return string(foldName(x)) == string(foldName(y)) } |
| 45 |
f.Fuzz(func(t *testing.T, x, y []byte) { |
| 46 |
got := equalFold(x, y) |
| 47 |
want := bytes.EqualFold(x, y) |
| 48 |
if got != want { |
| 49 |
t.Errorf("equalFold(%q, %q) = %v, want %v", x, y, got, want) |
| 50 |
} |
| 51 |
}) |
| 52 |
} |