// Test SML writer processing. func TestSMLWriterProcessing(t *testing.T) { assert := asserts.NewTestingAsserts(t, true) root := createSMLStructure() bufA := bytes.NewBufferString("") bufB := bytes.NewBufferString("") markup.WriteSML(root, bufA, true) markup.WriteSML(root, bufB, false) println("===== WITH INDENT =====") println(bufA.String()) println("===== WITHOUT INDENT =====") println(bufB.String()) println("===== DONE =====") assert.NotEmpty(bufA, "Buffer A should not be empty.") assert.NotEmpty(bufB, "Buffer B should not be empty.") }
// Test positive reading. func TestSMLPositiveReading(t *testing.T) { assert := asserts.NewTestingAsserts(t, true) sml := "Before! {foo {bar:1:first Yadda ^{Test^} 1} {! Raw: }} { ! ^^^ !} {inbetween} {bar:2:last Yadda {Test ^^} 2}} After!" builder := markup.NewNodeBuilder() err := markup.ReadSML(strings.NewReader(sml), builder) assert.Nil(err, "Expected no reader error.") root := builder.Root() assert.Equal(root.Tag(), "foo", "Root tag is 'foo'.") assert.NotEmpty(root, "Root tag is not empty.") buf := bytes.NewBufferString("") markup.WriteSML(root, buf, true) println("===== PARSED SML =====") println(buf.String()) println("===== DONE =====") }