You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
516 B
38 lines
516 B
package jsonlint |
|
|
|
import ( |
|
"bytes" |
|
"testing" |
|
) |
|
|
|
var testdata = ` |
|
{ |
|
"a1": "a1", |
|
"b2": |
|
} |
|
` |
|
|
|
var testdataok = ` |
|
{ |
|
"hello": "world" |
|
} |
|
` |
|
|
|
func TestJsonLint(t *testing.T) { |
|
lint := jsonlint{} |
|
r := bytes.NewBufferString(testdata) |
|
lintErr := lint.Lint(r) |
|
if lintErr == nil { |
|
t.Fatalf("expect lintErr != nil") |
|
} |
|
t.Logf("%s", lintErr.Error()) |
|
} |
|
|
|
func TestJsonLintOk(t *testing.T) { |
|
lint := jsonlint{} |
|
r := bytes.NewBufferString(testdataok) |
|
lintErr := lint.Lint(r) |
|
if lintErr != nil { |
|
t.Error(lintErr) |
|
} |
|
}
|
|
|