Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jensneuse committed Nov 8, 2024
1 parent bfaa986 commit ec56ce3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1264,3 +1264,27 @@ func testParseGetSerial(s string) error {
}
return nil
}

func TestParseBytesWithoutCache(t *testing.T) {
var p Parser
v, err := p.ParseBytesWithoutCache([]byte(`{"foo": "bar"}`))
if err != nil {
t.Fatalf("cannot parse json: %s", err)
}
sb := v.GetStringBytes("foo")
if string(sb) != "bar" {
t.Fatalf("unexpected value for key=%q; got %q; want %q", "foo", sb, "bar")
}
}

func TestParseWithoutCache(t *testing.T) {
var p Parser
v, err := p.ParseWithoutCache(`{"foo": "bar"}`)
if err != nil {
t.Fatalf("cannot parse json: %s", err)
}
sb := v.GetStringBytes("foo")
if string(sb) != "bar" {
t.Fatalf("unexpected value for key=%q; got %q; want %q", "foo", sb, "bar")
}
}

0 comments on commit ec56ce3

Please sign in to comment.