From a4fc9176cd7ba247cd79cb389506db5e7b1afb4e Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L de Mello" Date: Thu, 22 May 2025 11:10:38 -0300 Subject: [PATCH] feat(attr,ipub): small mock test to test unmarshalling and marshalling --- ipub/element/element_test.go | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 ipub/element/element_test.go diff --git a/ipub/element/element_test.go b/ipub/element/element_test.go new file mode 100644 index 0000000..7688fcd --- /dev/null +++ b/ipub/element/element_test.go @@ -0,0 +1,47 @@ +package element_test + +import ( + "encoding/xml" + "testing" + + "forge.capytal.company/capytalcode/project-comicverse/ipub/element" +) + +func Test(t *testing.T) { + d := element.Section{ + Body: element.Body{ + Test: "helloworld", + Children: []element.Element{ + &element.Paragraph{ + DataElement: element.ParagraphKind, + Text: "hello world", + Test: "testvalue", + }, + &element.Paragraph{ + DataElement: element.ParagraphKind, + + Text: "hello world 2", + }, + }, + }, + } + + b, err := xml.Marshal(d) + if err != nil { + t.Error(err.Error()) + t.FailNow() + } + + t.Logf("%#v", string(b)) + + var ud element.Section + err = xml.Unmarshal(b, &ud) + if err != nil { + t.Error(err) + t.FailNow() + } + + t.Logf("%#v", ud) + t.Logf("%#v", ud.Body.Children[0]) + t.Logf("%#v", ud.Body.Children[1]) +}