Add support of mixed-type array (#376)

Fixes #357
This commit is contained in:
Allen
2020-05-07 11:07:57 +08:00
committed by GitHub
parent 9ccd9bbc7a
commit c5fbd3eba6
6 changed files with 122 additions and 50 deletions
+1 -13
View File
@@ -488,18 +488,6 @@ func TestNestedEmptyArrays(t *testing.T) {
})
}
func TestArrayMixedTypes(t *testing.T) {
_, err := Load("a = [42, 16.0]")
if err.Error() != "(1, 10): mixed types in array" {
t.Error("Bad error message:", err.Error())
}
_, err = Load("a = [42, \"hello\"]")
if err.Error() != "(1, 11): mixed types in array" {
t.Error("Bad error message:", err.Error())
}
}
func TestArrayNestedStrings(t *testing.T) {
tree, err := Load("data = [ [\"gamma\", \"delta\"], [\"Foo\"] ]")
assertTree(t, tree, err, map[string]interface{}{
@@ -934,7 +922,7 @@ func TestTomlValueStringRepresentation(t *testing.T) {
{[]interface{}{"gamma", "delta"}, "[\"gamma\",\"delta\"]"},
{nil, ""},
} {
result, err := tomlValueStringRepresentation(item.Value, "", "", false)
result, err := tomlValueStringRepresentation(item.Value, "", "", OrderPreserve, false)
if err != nil {
t.Errorf("Test %d - unexpected error: %s", idx, err)
}