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.
40 lines
961 B
Go
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)
|
|
}
|
|
}
|