Splitting the structure tests

This commit is contained in:
tombuildsstuff 2017-03-27 17:54:21 +01:00
parent 459c9a0a5a
commit 6efdc94ae3
1 changed files with 6 additions and 6 deletions

View File

@ -4,10 +4,7 @@ import (
"testing"
)
func TestNormalizeJsonString(t *testing.T) {
var err error
var actual string
func TestNormalizeJsonString_valid(t *testing.T) {
// Well formatted and valid.
validJson := `{
"abc": {
@ -24,7 +21,7 @@ func TestNormalizeJsonString(t *testing.T) {
}`
expected := `{"abc":{"def":123,"xyz":[{"a":"ホリネズミ"},{"b":"1\\n2"}]}}`
actual, err = NormalizeJsonString(validJson)
actual, err := NormalizeJsonString(validJson)
if err != nil {
t.Fatalf("Expected not to throw an error while parsing JSON, but got: %s", err)
}
@ -32,7 +29,9 @@ func TestNormalizeJsonString(t *testing.T) {
if actual != expected {
t.Fatalf("Got:\n\n%s\n\nExpected:\n\n%s\n", actual, expected)
}
}
func TestNormalizeJsonString_invalid(t *testing.T) {
// Well formatted but not valid,
// missing closing squre bracket.
invalidJson := `{
@ -45,7 +44,8 @@ func TestNormalizeJsonString(t *testing.T) {
}
}
}`
actual, err = NormalizeJsonString(invalidJson)
expected := `{"abc":{"def":123,"xyz":[{"a":"ホリネズミ"},{"b":"1\\n2"}]}}`
actual, err := NormalizeJsonString(invalidJson)
if err == nil {
t.Fatalf("Expected to throw an error while parsing JSON, but got: %s", err)
}