diff options
Diffstat (limited to 'src/encoding/json/encode_test.go')
| -rw-r--r-- | src/encoding/json/encode_test.go | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/encoding/json/encode_test.go b/src/encoding/json/encode_test.go index c1b9ed2676..d027972d8a 100644 --- a/src/encoding/json/encode_test.go +++ b/src/encoding/json/encode_test.go @@ -15,7 +15,6 @@ import ( "runtime/debug" "strconv" "testing" - "unicode" ) type Optionals struct { @@ -701,54 +700,6 @@ func TestDuplicatedFieldDisappears(t *testing.T) { } } -func TestStringBytes(t *testing.T) { - t.Parallel() - // Test that encodeState.stringBytes and encodeState.string use the same encoding. - var r []rune - for i := '\u0000'; i <= unicode.MaxRune; i++ { - if testing.Short() && i > 1000 { - i = unicode.MaxRune - } - r = append(r, i) - } - s := string(r) + "\xff\xff\xffhello" // some invalid UTF-8 too - - for _, escapeHTML := range []bool{true, false} { - es := &encodeState{} - es.string(s, escapeHTML) - - esBytes := &encodeState{} - esBytes.stringBytes([]byte(s), escapeHTML) - - enc := es.Buffer.String() - encBytes := esBytes.Buffer.String() - if enc != encBytes { - i := 0 - for i < len(enc) && i < len(encBytes) && enc[i] == encBytes[i] { - i++ - } - enc = enc[i:] - encBytes = encBytes[i:] - i = 0 - for i < len(enc) && i < len(encBytes) && enc[len(enc)-i-1] == encBytes[len(encBytes)-i-1] { - i++ - } - enc = enc[:len(enc)-i] - encBytes = encBytes[:len(encBytes)-i] - - if len(enc) > 20 { - enc = enc[:20] + "..." - } - if len(encBytes) > 20 { - encBytes = encBytes[:20] + "..." - } - - t.Errorf("with escapeHTML=%t, encodings differ at %#q vs %#q", - escapeHTML, enc, encBytes) - } - } -} - func TestIssue10281(t *testing.T) { type Foo struct { N Number |
