diff options
| author | 2026-02-16 16:31:54 -0500 | |
|---|---|---|
| committer | 2026-02-16 16:31:54 -0500 | |
| commit | ca90ebdfa8789654766c5d7969baa7afacd9ebd2 (patch) | |
| tree | 9693e0c7a5af6713f4c5e39372dcf22d05844ec3 /common/infostring/infostring_test.go | |
Diffstat (limited to '')
| -rw-r--r-- | common/infostring/infostring_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/common/infostring/infostring_test.go b/common/infostring/infostring_test.go new file mode 100644 index 0000000..977090d --- /dev/null +++ b/common/infostring/infostring_test.go @@ -0,0 +1,49 @@ +package infostring + +import ( + "reflect" + "testing" +) + +type infoStringTest struct { + name string + input string + expected InfoString +} + +var infoStringTests = []infoStringTest{ + { + name: "foo", + input: "\"\\FOO\\foo\\BAR\\bar\\BAZ\\baz\"", + expected: InfoString{ + Info: []Info{ + Info{Key: "FOO", Value: "foo"}, + Info{Key: "BAR", Value: "bar"}, + Info{Key: "BAZ", Value: "baz"}, + }, + }, + }, + { + name: "\\foo\\with spaces", + input: "\"\\foo\\with spaces\"", + expected: InfoString{ + Info: []Info{ + Info{Key: "foo", Value: "with spaces"}, + }, + }, + }, +} + +func TestInfoString(t *testing.T) { + for _, is := range infoStringTests { + t.Run(is.name, func(t *testing.T) { + infoString := Parse(is.input) + + if !reflect.DeepEqual(is.expected.Bytes(), infoString.Bytes()) { + t.Errorf("parsed infostring output didn't match") + t.Logf("output: %#v\n", infoString) + t.Logf("expected: %#v\n", is.expected) + } + }) + } +} |
