| 1 | // Copyright 2010 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package jsonld |
| 6 | |
| 7 | import ( |
| 8 | "testing" |
| 9 | ) |
| 10 | |
| 11 | var validTests = []struct { |
| 12 | data string |
| 13 | ok bool |
| 14 | }{ |
| 15 | {`foo`, false}, |
| 16 | {`}{`, false}, |
| 17 | {`{]`, false}, |
| 18 | {`{}`, true}, |
| 19 | {`{"foo":"bar"}`, true}, |
| 20 | {`{"foo":"bar","bar":{"baz":["qux"]}}`, true}, |
| 21 | } |
| 22 | |
| 23 | func TestValid(t *testing.T) { |
| 24 | for _, tt := range validTests { |
| 25 | if ok := Valid([]byte(tt.data)); ok != tt.ok { |
| 26 | t.Errorf("Valid(%#q) = %v, want %v", tt.data, ok, tt.ok) |
| 27 | } |
| 28 | } |
| 29 | } |