Skip to content

Commit

Permalink
feat(raw): add String
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Nov 5, 2021
1 parent c5a4233 commit 3a468c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dec_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ func (r Raw) Type() Type {
d := Decoder{buf: r, tail: len(r)}
return d.Next()
}

func (r Raw) String() string { return string(r) }
5 changes: 4 additions & 1 deletion dec_raw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package jx
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand All @@ -13,7 +14,9 @@ func TestDecoder_Raw(t *testing.T) {
d := DecodeStr(v)
require.NoError(t, d.Obj(func(d *Decoder, key string) error {
raw, err := d.Raw()
require.NoError(t, err)
assert.NoError(t, err)
assert.Equal(t, Array, raw.Type())
assert.Equal(t, `[1, 2, 3, 4, 5]`, raw.String())
t.Logf("%q", raw)
return err
}))
Expand Down

0 comments on commit 3a468c1

Please sign in to comment.