1
0
textedit/escape_test.go

20 lines
387 B
Go
Raw Normal View History

2025-11-01 03:49:02 +01:00
package textedit_test
import (
"bytes"
"code.squareroundforest.org/arpio/textedit"
"testing"
)
func TestEscape(t *testing.T) {
t.Run("basic", func(t *testing.T) {
var b bytes.Buffer
w := textedit.New(&b, textedit.Escape('\\', '\n', '\t', '"'))
2025-11-01 05:14:20 +01:00
w.Write([]byte("foo\nbar\t\"baz\""))
w.Flush()
2025-11-01 03:49:02 +01:00
if b.String() != "foo\\\nbar\\\t\\\"baz\\\"" {
t.Fatal(b.String())
}
})
}