(t *testing.T)
| 78 | } |
| 79 | |
| 80 | func TestUnmarshalAsJSONNumericMapKeys(t *testing.T) { |
| 81 | var buf bytes.Buffer |
| 82 | enc := NewWriter(&buf) |
| 83 | enc.WriteMapHeader(2) |
| 84 | enc.WriteInt64(-5) |
| 85 | enc.WriteString("neg") |
| 86 | enc.WriteUint64(42) |
| 87 | enc.WriteString("pos") |
| 88 | enc.Flush() |
| 89 | |
| 90 | var js bytes.Buffer |
| 91 | if _, err := UnmarshalAsJSON(&js, buf.Bytes()); err != nil { |
| 92 | t.Fatal(err) |
| 93 | } |
| 94 | mp := make(map[string]any) |
| 95 | if err := json.Unmarshal(js.Bytes(), &mp); err != nil { |
| 96 | t.Fatalf("unmarshal: %s — json: %s", err, js.String()) |
| 97 | } |
| 98 | if mp["-5"] != "neg" || mp["42"] != "pos" { |
| 99 | t.Errorf("unexpected map: %v", mp) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | func BenchmarkUnmarshalAsJSON(b *testing.B) { |
| 104 | var buf bytes.Buffer |
nothing calls this directly
no test coverage detected
searching dependent graphs…