Skip to content

Commit

Permalink
Fix backspace and form-feed for Go 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Feb 15, 2024
1 parent 711c6fe commit bbf40bb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions gjson_test.go
Expand Up @@ -2578,15 +2578,19 @@ func TestJSONString(t *testing.T) {
testJSONString(t, s)
testJSONString(t, "R\xfd\xfc\a!\x82eO\x16?_\x0f\x9ab\x1dr")
testJSONString(t, "_\xb9\v\xad\xb3|X!\xb6\xd9U&\xa4\x1a\x95\x04")
testJSONString(t, "\b\f")
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
start := time.Now()
var buf [16]byte
for time.Since(start) < time.Second*2 {
if _, err := rng.Read(buf[:]); err != nil {
t.Fatal(err)
data, _ := json.Marshal("\b\f")
if (string(data) == "\"\\b\\f\"") {
// Go version 1.22+ encodes "\b" and "\f" correctly.
testJSONString(t, "\b\f")
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
start := time.Now()
var buf [16]byte
for time.Since(start) < time.Second*2 {
if _, err := rng.Read(buf[:]); err != nil {
t.Fatal(err)
}
testJSONString(t, string(buf[:]))
}
testJSONString(t, string(buf[:]))
}
}

Expand Down

0 comments on commit bbf40bb

Please sign in to comment.