(t *testing.T)
| 2572 | } |
| 2573 | |
| 2574 | func TestJSONString(t *testing.T) { |
| 2575 | testJSONString(t, "hello") |
| 2576 | testJSONString(t, "he\"llo") |
| 2577 | testJSONString(t, "he\"l\\lo") |
| 2578 | const input = `{"utf8":"Example emoji, KO: \ud83d\udd13, \ud83c\udfc3 ` + |
| 2579 | `OK: \u2764\ufe0f "}` |
| 2580 | value := Get(input, "utf8") |
| 2581 | var s string |
| 2582 | json.Unmarshal([]byte(value.Raw), &s) |
| 2583 | if value.String() != s { |
| 2584 | t.Fatalf("expected '%v', got '%v'", s, value.String()) |
| 2585 | } |
| 2586 | testJSONString(t, s) |
| 2587 | testJSONString(t, "R\xfd\xfc\a!\x82eO\x16?_\x0f\x9ab\x1dr") |
| 2588 | testJSONString(t, "_\xb9\v\xad\xb3|X!\xb6\xd9U&\xa4\x1a\x95\x04") |
| 2589 | data, _ := json.Marshal("\b\f") |
| 2590 | if string(data) == "\"\\b\\f\"" { |
| 2591 | // Go version 1.22+ encodes "\b" and "\f" correctly. |
| 2592 | testJSONString(t, "\b\f") |
| 2593 | rng := rand.New(rand.NewSource(time.Now().UnixNano())) |
| 2594 | start := time.Now() |
| 2595 | var buf [16]byte |
| 2596 | for time.Since(start) < time.Second*2 { |
| 2597 | if _, err := rng.Read(buf[:]); err != nil { |
| 2598 | t.Fatal(err) |
| 2599 | } |
| 2600 | testJSONString(t, string(buf[:])) |
| 2601 | } |
| 2602 | } |
| 2603 | } |
| 2604 | |
| 2605 | func TestIndexAtSymbol(t *testing.T) { |
| 2606 | json := `{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…