Esempio n. 1
0
// Test negative reading.
func TestSMLNegativeReading(t *testing.T) {
	assert := asserts.NewTestingAsserts(t, true)
	sml := "{Foo {bar:1 Yadda {test} {} 1} {bar:2 Yadda 2}}"
	builder := markup.NewNodeBuilder()
	err := markup.ReadSML(strings.NewReader(sml), builder)
	assert.ErrorMatch(err, "invalid rune.*", "Invalid rune should be found.")
}
Esempio n. 2
0
// 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 =====")
}