Fix JSON encoding removing null #985

This commit is contained in:
Mike Farah
2021-10-30 13:37:21 +11:00
parent 2b3d0552a6
commit 08fc058934
2 changed files with 20 additions and 1 deletions
+18
View File
@@ -48,6 +48,24 @@ banana:
test.AssertResult(t, expectedJson, actualJson)
}
func TestJsonNullInArray(t *testing.T) {
var sampleYaml = `[null]`
var actualJson = yamlToJson(sampleYaml, 0)
test.AssertResult(t, sampleYaml, actualJson)
}
func TestJsonNull(t *testing.T) {
var sampleYaml = `null`
var actualJson = yamlToJson(sampleYaml, 0)
test.AssertResult(t, sampleYaml, actualJson)
}
func TestJsonNullInObject(t *testing.T) {
var sampleYaml = `{x: null}`
var actualJson = yamlToJson(sampleYaml, 0)
test.AssertResult(t, `{"x":null}`, actualJson)
}
func TestJsonEncoderDoesNotEscapeHTMLChars(t *testing.T) {
var sampleYaml = `build: "( ./lint && ./format && ./compile ) < src.code"`
var expectedJson = `{"build":"( ./lint && ./format && ./compile ) < src.code"}`