Pad/internal/editor/buffer_test.go
Greg Pomerantz 06b1444207 gofmt: format all remaining files with the go1.27 toolchain
The tree was formatted with an older gofmt; go1.27's gofmt additionally
wants: EOF exactly one newline (no trailing blank lines), imports sorted
alphabetically within a block, mixed-precedence binary expressions
re-spaced for grouping ((a+b)/c), single-field composite literals
un-aligned, adjacent one-line method signatures aligned, and one-line
bodies containing a compound statement expanded. Applied repo-wide
(31 files under internal/); pure formatting, no semantic changes —
build and the full test suite pass.
2026-08-23 10:03:27 -04:00

40 lines
961 B
Go

package editor
import (
"testing"
)
func TestInsertChar(t *testing.T) {
state := NewState()
TheState = state
state.Editor.Buffer = "Hello"
state.Editor.CursorPosition = 5 // End of "Hello"
HandleInsert("!") // Assuming we create this function
expected := "Hello!"
if state.Editor.Buffer != expected {
t.Errorf("Expected buffer %q, got %q", expected, state.Editor.Buffer)
}
if state.Editor.CursorPosition != 6 {
t.Errorf("Expected cursor position 6, got %d", state.Editor.CursorPosition)
}
}
func TestBackspace(t *testing.T) {
state := NewState()
TheState = state
state.Editor.Buffer = "Hello"
state.Editor.CursorPosition = 5
HandleBackspace() // Assuming we create this function
expected := "Hell"
if state.Editor.Buffer != expected {
t.Errorf("Expected buffer %q, got %q", expected, state.Editor.Buffer)
}
if state.Editor.CursorPosition != 4 {
t.Errorf("Expected cursor position 4, got %d", state.Editor.CursorPosition)
}
}