1
0
textedit/singleline_test.go

30 lines
660 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 TestSingleLine(t *testing.T) {
t.Run("basic", func(t *testing.T) {
var b bytes.Buffer
w := textedit.New(&b, textedit.SingleLine())
2025-11-01 05:14:20 +01:00
w.Write([]byte("\nfoo bar\n\nbaz \nqux quux\n"))
w.Flush()
2025-11-01 03:49:02 +01:00
if b.String() != "foo bar baz qux quux" {
t.Fatal(b.String())
}
})
2025-11-02 01:23:00 +01:00
t.Run("two lines", func(t *testing.T) {
var b bytes.Buffer
w := textedit.New(&b, textedit.SingleLine())
w.Write([]byte("Some sample text...\nwith invalid chars."))
w.Flush()
if b.String() != "Some sample text... with invalid chars." {
t.Fatal(b.String())
}
})
2025-11-01 03:49:02 +01:00
}