summaryrefslogtreecommitdiff
path: root/libgo/go/encoding/json/scanner_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/encoding/json/scanner_test.go')
-rw-r--r--libgo/go/encoding/json/scanner_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/libgo/go/encoding/json/scanner_test.go b/libgo/go/encoding/json/scanner_test.go
index c5c1be31f1e..0d4518a632b 100644
--- a/libgo/go/encoding/json/scanner_test.go
+++ b/libgo/go/encoding/json/scanner_test.go
@@ -12,6 +12,26 @@ import (
"testing"
)
+var validTests = []struct {
+ data string
+ ok bool
+}{
+ {`foo`, false},
+ {`}{`, false},
+ {`{]`, false},
+ {`{}`, true},
+ {`{"foo":"bar"}`, true},
+ {`{"foo":"bar","bar":{"baz":["qux"]}}`, true},
+}
+
+func TestValid(t *testing.T) {
+ for _, tt := range validTests {
+ if ok := Valid([]byte(tt.data)); ok != tt.ok {
+ t.Errorf("Valid(%#q) = %v, want %v", tt.data, ok, tt.ok)
+ }
+ }
+}
+
// Tests of simple examples.
type example struct {