blob: 5c8f3eea21cdf650e375fcf86e98d5586693aafb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// Copyright (C) 2023 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
package json
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCompatValid(t *testing.T) {
t.Parallel()
type testcase struct {
In string
Exp bool
}
testcases := map[string]testcase{
"empty": {In: ``, Exp: false},
"num": {In: `1`, Exp: true},
"trunc": {In: `{`, Exp: false},
"object": {In: `{}`, Exp: true},
}
for tcName, tc := range testcases {
tc := tc
t.Run(tcName, func(t *testing.T) {
t.Parallel()
t.Logf("in=%q", tc.In)
act := Valid([]byte(tc.In))
assert.Equal(t, tc.Exp, act)
})
}
}
|