diff --git a/writemetapropertycontent.go b/writemetapropertycontent.go new file mode 100644 index 0000000..00f450f --- /dev/null +++ b/writemetapropertycontent.go @@ -0,0 +1,19 @@ +package frameproto + +import ( + "io" +) + +func writeMetaPropertyContent(writer io.Writer, property string, content string) { + + if nil == writer { + return + } + + var buffer [bufferSize]byte + var p []byte = buffer[0:0] + + p = appendMetaPropertyContent(p, property, content) + + writer.Write(p) +} diff --git a/writemetapropertycontent_test.go b/writemetapropertycontent_test.go new file mode 100644 index 0000000..60c2091 --- /dev/null +++ b/writemetapropertycontent_test.go @@ -0,0 +1,80 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteMetaPropertyContent(t *testing.T) { + + tests := []struct{ + Property string + Content string + Expected string + }{ + { + Property: "", + Content: "", + Expected: ``+"\n", + }, + + + + { + Property: "name", + Content: "value", + Expected: ``+"\n", + }, + + + + { + Property: "test", + Content: "5 > 3", + Expected: ``+"\n", + }, + { + Property: "test", + Content: "5 < 3", + Expected: ``+"\n", + }, + + + + { + Property: "quotation", + Content: `she said, "hello! 🙂"`, + Expected: ``+"\n", + }, + + + + { + Property: "apple\tbanana\tcherry", + Content: "\x00\x01\x02\x03\x04\x05\x06\x07\x08", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + writeMetaPropertyContent(&buffer, test.Property, test.Content) + + expected := test.Expected + actual := buffer.String() + + if expected != actual { + t.Errorf("For test #%d, the actual rendered tag is not what was expected." , testNumber) + t.Logf("EXPECTED: %s", expected) + t.Logf("ACTUAL: %s", actual) + t.Logf("EXPECTED: %q", expected) + t.Logf("ACTUAL: %q", actual) + t.Logf("PROPERTY: %s", test.Property) + t.Logf("CONTENT: %s", test.Content) + continue + } + } +}