2015-10-10 23:00:22 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestJsonToString(t *testing.T) {
|
|
|
|
var data = parseData(`
|
|
|
|
---
|
|
|
|
b:
|
|
|
|
c: 2
|
|
|
|
`)
|
2017-09-22 19:58:12 +00:00
|
|
|
got, _ := jsonToString(data)
|
|
|
|
assertResult(t, "{\"b\":{\"c\":2}}", got)
|
2015-10-10 23:00:22 +00:00
|
|
|
}
|
|
|
|
|
2017-09-21 16:01:03 +00:00
|
|
|
func TestJsonToString_withIntKey(t *testing.T) {
|
|
|
|
var data = parseData(`
|
|
|
|
---
|
|
|
|
b:
|
|
|
|
2: c
|
|
|
|
`)
|
2017-09-22 19:58:12 +00:00
|
|
|
got, _ := jsonToString(data)
|
|
|
|
assertResult(t, `{"b":{"2":"c"}}`, got)
|
2017-09-21 16:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestJsonToString_withBoolKey(t *testing.T) {
|
|
|
|
var data = parseData(`
|
|
|
|
---
|
|
|
|
b:
|
|
|
|
false: c
|
|
|
|
`)
|
2017-09-22 19:58:12 +00:00
|
|
|
got, _ := jsonToString(data)
|
|
|
|
assertResult(t, `{"b":{"false":"c"}}`, got)
|
2017-09-21 16:01:03 +00:00
|
|
|
}
|
|
|
|
|
2015-10-10 23:00:22 +00:00
|
|
|
func TestJsonToString_withArray(t *testing.T) {
|
|
|
|
var data = parseData(`
|
|
|
|
---
|
|
|
|
b:
|
|
|
|
- item: one
|
|
|
|
- item: two
|
|
|
|
`)
|
2017-09-22 19:58:12 +00:00
|
|
|
got, _ := jsonToString(data)
|
|
|
|
assertResult(t, "{\"b\":[{\"item\":\"one\"},{\"item\":\"two\"}]}", got)
|
2015-10-10 23:00:22 +00:00
|
|
|
}
|