diff --git a/ipub/ast/ast_test.go b/ipub/ast/ast_test.go index f1b79ef..2210807 100644 --- a/ipub/ast/ast_test.go +++ b/ipub/ast/ast_test.go @@ -38,3 +38,40 @@ func TestMarshal(t *testing.T) { t.Logf("%#v", string(by)) } +func TestUnmarshal(t *testing.T) { + assert := tinyssert.New(tinyssert.WithTest(t), tinyssert.WithPanic()) + + s := []byte(` + + +
+ +
+ + + `) + + var data ast.Section + + err := xml.Unmarshal(s, &data) + if err != nil && err != io.EOF { + t.Error(err.Error()) + t.FailNow() + } + + body := data.Body + assert.Equal(ast.KindBody, body.Kind()) + + t.Logf("%#v", body) + + content := body.FirstChild() + assert.Equal(ast.KindContent, content.Kind()) + + t.Logf("%#v", content) + + img := content.FirstChild().(*ast.Image) + assert.Equal(ast.KindImage, img.Kind()) + assert.Equal("https://hello.com/world.png", img.Source()) + + t.Logf("%#v", img) +}