summaryrefslogtreecommitdiff
path: root/pkg/gitdiff/format_test.go
diff options
context:
space:
mode:
authorAnton Medvedev <anton@medv.io>2025-11-30 12:46:34 +0100
committerAnton Medvedev <anton@medv.io>2025-11-30 12:46:34 +0100
commitf6b0f38af648d028422a7494378b5dabdc90573f (patch)
tree3c26cfc269c021300a2d1e4e02623dd440c20226 /pkg/gitdiff/format_test.go
First commit
Diffstat (limited to 'pkg/gitdiff/format_test.go')
-rw-r--r--pkg/gitdiff/format_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/pkg/gitdiff/format_test.go b/pkg/gitdiff/format_test.go
new file mode 100644
index 0000000..3325296
--- /dev/null
+++ b/pkg/gitdiff/format_test.go
@@ -0,0 +1,28 @@
+package gitdiff
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestFormatter_WriteQuotedName(t *testing.T) {
+ tests := []struct {
+ Input string
+ Expected string
+ }{
+ {"noquotes.txt", `noquotes.txt`},
+ {"no quotes.txt", `no quotes.txt`},
+ {"new\nline", `"new\nline"`},
+ {"escape\x1B null\x00", `"escape\033 null\000"`},
+ {"snowman \u2603 snowman", `"snowman \342\230\203 snowman"`},
+ {"\"already quoted\"", `"\"already quoted\""`},
+ }
+
+ for _, test := range tests {
+ var b strings.Builder
+ newFormatter(&b).WriteQuotedName(test.Input)
+ if b.String() != test.Expected {
+ t.Errorf("expected %q, got %q", test.Expected, b.String())
+ }
+ }
+}