Allow unmarshal from any TomlTree (#157)

Fixes #153
This commit is contained in:
John K. Luebs
2017-05-05 19:29:08 -04:00
committed by Thomas Pelletier
parent 97253b98df
commit 53be957dac
2 changed files with 35 additions and 13 deletions
+17
View File
@@ -177,6 +177,23 @@ func TestDocUnmarshal(t *testing.T) {
}
}
func TestDocPartialUnmarshal(t *testing.T) {
result := testDocSubs{}
tree, _ := LoadFile("marshal_test.toml")
subTree := tree.Get("subdoc").(*TomlTree)
err := subTree.Unmarshal(&result)
expected := docData.Subdocs
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(result, expected) {
resStr, _ := json.MarshalIndent(result, "", " ")
expStr, _ := json.MarshalIndent(expected, "", " ")
t.Errorf("Bad partial unmartial: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expStr, resStr)
}
}
type tomlTypeCheckTest struct {
name string
item interface{}