summaryrefslogtreecommitdiff
path: root/decode_test.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2022-08-21 21:39:59 -0600
committerLuke Shumaker <lukeshu@datawire.io>2022-08-21 21:39:59 -0600
commit325838f35ce90080aa6c892a998d960c06c1c144 (patch)
tree60e87ee9a622a0261b93ef1e47dbca632c588276 /decode_test.go
parentd25456172946e5921747cd57fb04eb5b6da72fb6 (diff)
Add tests for the actual usability of the Decodable and Encodable interfaces
Diffstat (limited to 'decode_test.go')
-rw-r--r--decode_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/decode_test.go b/decode_test.go
index 8220e39..a9e81e0 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -5,6 +5,7 @@
package lowmemjson
import (
+ "io"
"strings"
"testing"
@@ -19,3 +20,15 @@ func TestDecodeNumber(t *testing.T) {
assert.Equal(t, 1, num)
assert.Equal(t, 2, r.Len()) // check that it didn't read too far
}
+
+func TestDecodeObject(t *testing.T) {
+ err := DecodeObject(strings.NewReader(`{"foo":9}`),
+ func(r io.RuneScanner) error {
+ return nil
+ },
+ func(r io.RuneScanner) error {
+ var n int
+ return Decode(r, &n)
+ })
+ assert.ErrorContains(t, err, "did not consume entire")
+}