24 lines
599 B
Go
24 lines
599 B
Go
package editor
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// TestByteOffsetToLineCol_Logical verifies that the current logic
|
|
// only handles logical lines (newline-delimited).
|
|
func TestByteOffsetToLineCol_Logical(t *testing.T) {
|
|
buf := "hello\nworld"
|
|
// 012345 67890
|
|
|
|
// Logical line 0: "hello" (0-4), pos 5 is '\n', line 1 starts at 6
|
|
line, col := byteOffsetToLineCol(buf, 5)
|
|
if line != 0 || col != 5 {
|
|
t.Errorf("expected (0, 5) for pos 5, got (%d, %d)", line, col)
|
|
}
|
|
|
|
line, col = byteOffsetToLineCol(buf, 6)
|
|
if line != 1 || col != 0 {
|
|
t.Errorf("expected (1, 0) for pos 6, got (%d, %d)", line, col)
|
|
}
|
|
}
|