This commit is contained in:
parent
587dfc686a
commit
a2bfb5f945
50
editor/buffer_test.go
Normal file
50
editor/buffer_test.go
Normal file
@ -0,0 +1,50 @@
|
||||
package editor
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestBufferAppendRune(t *testing.T) {
|
||||
b := newBuffer()
|
||||
|
||||
got := b.appendRune('a')
|
||||
want := 1
|
||||
|
||||
if got != want {
|
||||
t.Errorf("Wrong length for rune, got %q, expected %q for rune %c", got, want, 'a')
|
||||
}
|
||||
}
|
||||
|
||||
func TestBufferAppend(t *testing.T) {
|
||||
b := newBuffer()
|
||||
|
||||
got := b.append("123")
|
||||
want := 3
|
||||
|
||||
if got != want {
|
||||
t.Errorf("Wrong length for string, got %d, expected %d for input '%s'", got, want, "123")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBufferAppendLn(t *testing.T) {
|
||||
b := newBuffer()
|
||||
|
||||
got := b.appendLn("123")
|
||||
|
||||
// Adds carriage return and line feed
|
||||
want := 5
|
||||
|
||||
if got != want {
|
||||
t.Errorf("Wrong length for string, got %d, expected %d for input '%s'", got, want, "123")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBufferToString(t *testing.T) {
|
||||
b := newBuffer()
|
||||
b.append("foo")
|
||||
|
||||
got := b.toString()
|
||||
want := "foo"
|
||||
|
||||
if got != want {
|
||||
t.Errorf("Failed to convert to proper string")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user