summaryrefslogtreecommitdiff
path: root/decode_test.go
blob: 8220e39c667e429ebae3b69c493267d24d4c6af5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
}