github.com/searKing/golang/go@v1.2.117/encoding/prettyjson/fold_test.go (about) 1 // Copyright 2023 The searKing Author. 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 package prettyjson 6 7 import ( 8 "bytes" 9 "testing" 10 ) 11 12 func FuzzEqualFold(f *testing.F) { 13 for _, ss := range [][2]string{ 14 {"", ""}, 15 {"123abc", "123ABC"}, 16 {"αβδ", "ΑΒΔ"}, 17 {"abc", "xyz"}, 18 {"abc", "XYZ"}, 19 {"1", "2"}, 20 {"hello, world!", "hello, world!"}, 21 {"hello, world!", "Hello, World!"}, 22 {"hello, world!", "HELLO, WORLD!"}, 23 {"hello, world!", "jello, world!"}, 24 {"γειά, κόσμε!", "γειά, κόσμε!"}, 25 {"γειά, κόσμε!", "Γειά, Κόσμε!"}, 26 {"γειά, κόσμε!", "ΓΕΙΆ, ΚΌΣΜΕ!"}, 27 {"γειά, κόσμε!", "ΛΕΙΆ, ΚΌΣΜΕ!"}, 28 {"AESKey", "aesKey"}, 29 {"AESKEY", "aes_key"}, 30 {"aes_key", "AES_KEY"}, 31 {"AES_KEY", "aes-key"}, 32 {"aes-key", "AES-KEY"}, 33 {"AES-KEY", "aesKey"}, 34 {"aesKey", "AesKey"}, 35 {"AesKey", "AESKey"}, 36 {"AESKey", "aeskey"}, 37 {"DESKey", "aeskey"}, 38 {"AES Key", "aeskey"}, 39 } { 40 f.Add([]byte(ss[0]), []byte(ss[1])) 41 } 42 equalFold := func(x, y []byte) bool { return string(foldName(x)) == string(foldName(y)) } 43 f.Fuzz(func(t *testing.T, x, y []byte) { 44 got := equalFold(x, y) 45 want := bytes.EqualFold(x, y) 46 if got != want { 47 t.Errorf("equalFold(%q, %q) = %v, want %v", x, y, got, want) 48 } 49 }) 50 }