Skip to content

Commit e05a1f2

Browse files
author
Antoine Pelisse
committed
Clarify Invalid value and bring back the tests
1 parent 009936b commit e05a1f2

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

value/less_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"testing"
2121
)
2222

23+
var InvalidValue = struct{}{}
24+
2325
func TestValueLess(t *testing.T) {
2426
table := []struct {
2527
name string
@@ -29,6 +31,39 @@ func TestValueLess(t *testing.T) {
2931
eq bool
3032
}{
3133
{
34+
name: "Invalid-1",
35+
a: InvalidValue,
36+
b: InvalidValue,
37+
eq: true,
38+
}, {
39+
name: "Invalid-2",
40+
a: 1.,
41+
b: InvalidValue,
42+
}, {
43+
name: "Invalid-3",
44+
a: 1,
45+
b: InvalidValue,
46+
}, {
47+
name: "Invalid-4",
48+
a: "aoeu",
49+
b: InvalidValue,
50+
}, {
51+
name: "Invalid-5",
52+
a: true,
53+
b: InvalidValue,
54+
}, {
55+
name: "Invalid-6",
56+
a: []interface{}{},
57+
b: InvalidValue,
58+
}, {
59+
name: "Invalid-7",
60+
a: map[string]interface{}{},
61+
b: InvalidValue,
62+
}, {
63+
name: "Invalid-8",
64+
a: nil,
65+
b: InvalidValue,
66+
}, {
3267
name: "Float-1",
3368
a: 1.14,
3469
b: 3.14,

value/value.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ var (
3131
writePool = jsoniter.NewStream(jsoniter.ConfigCompatibleWithStandardLibrary, nil, 1024).Pool()
3232
)
3333

34-
// A Value corresponds to an 'atom' in the schema.
34+
// A Value corresponds to an 'atom' in the schema. It should return true
35+
// for at least one of the IsXXX methods below, or the value is
36+
// considered "invalid"
3537
type Value interface {
3638
// IsMap returns true if the Value is a Map, false otherwise.
3739
IsMap() bool

0 commit comments

Comments
 (0)