diff options
Diffstat (limited to 'decode_test.go')
-rw-r--r-- | decode_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/decode_test.go b/decode_test.go new file mode 100644 index 0000000..8220e39 --- /dev/null +++ b/decode_test.go @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// +// SPDX-License-Identifier: GPL-2.0-or-later + +package lowmemjson + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDecodeNumber(t *testing.T) { + r := strings.NewReader(`1{}`) + + var num int + assert.NoError(t, Decode(r, &num)) + assert.Equal(t, 1, num) + assert.Equal(t, 2, r.Len()) // check that it didn't read too far +} |