MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestOffsetToLineColumn

Function TestOffsetToLineColumn

pkg/lsp/server_test.go:453–476  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

451}
452
453func TestOffsetToLineColumn(t *testing.T) {
454 content := "SELECT *\nFROM users\nWHERE id = 1"
455
456 tests := []struct {
457 offset int
458 expectedLine int
459 expectedCol int
460 }{
461 {0, 0, 0}, // Start of file
462 {6, 0, 6}, // "SELECT" -> 'T'
463 {9, 1, 0}, // After "SELECT *\n" -> start of line 1
464 {14, 1, 5}, // "FROM " -> space after FROM
465 {20, 2, 0}, // Start of line 2 (WHERE)
466 {100, 2, 11}, // Beyond end -> clamped to last char (content length is 32, so index 31 = col 11)
467 }
468
469 for _, tt := range tests {
470 line, col := offsetToLineColumn(content, tt.offset)
471 if line != tt.expectedLine || col != tt.expectedCol {
472 t.Errorf("offsetToLineColumn(%d) = (%d, %d), want (%d, %d)",
473 tt.offset, line, col, tt.expectedLine, tt.expectedCol)
474 }
475 }
476}
477
478func TestSnippetCompletions(t *testing.T) {
479 mock := newMockReadWriter()

Callers

nothing calls this directly

Calls 2

offsetToLineColumnFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected