From b63a4bd8923a97a9afca19ad7206a16f113f6ef0 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Thu, 15 Feb 2024 04:47:11 -0800 Subject: [PATCH] initial commits --- stringmetapropertycontent.go | 11 +++++ stringmetapropertycontent_test.go | 75 +++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 stringmetapropertycontent.go create mode 100644 stringmetapropertycontent_test.go diff --git a/stringmetapropertycontent.go b/stringmetapropertycontent.go new file mode 100644 index 0000000..095b5cd --- /dev/null +++ b/stringmetapropertycontent.go @@ -0,0 +1,11 @@ +package frameproto + +func stringMetaPropertyContent(property string, content string) string { + + var buffer [bufferSize]byte + var p []byte = buffer[0:0] + + p = appendMetaPropertyContent(p, property, content) + + return string(p) +} diff --git a/stringmetapropertycontent_test.go b/stringmetapropertycontent_test.go new file mode 100644 index 0000000..4cfc17c --- /dev/null +++ b/stringmetapropertycontent_test.go @@ -0,0 +1,75 @@ +package frameproto + +import ( + "testing" +) + +func TestStringMetaPropertyContent(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 { + + actual := stringMetaPropertyContent(test.Property, test.Content) + + expected := test.Expected + + 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 + } + } +}