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

Function TestDocumentGetWordAtPosition

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

Source from the content-addressed store, hash-verified

100}
101
102func TestDocumentGetWordAtPosition(t *testing.T) {
103 doc := &Document{
104 Content: "SELECT id FROM users WHERE active = true",
105 Lines: []string{"SELECT id FROM users WHERE active = true"},
106 }
107
108 tests := []struct {
109 pos Position
110 expected string
111 }{
112 {Position{Line: 0, Character: 0}, "SELECT"},
113 {Position{Line: 0, Character: 3}, "SELECT"},
114 {Position{Line: 0, Character: 7}, "id"},
115 {Position{Line: 0, Character: 14}, "FROM"},
116 {Position{Line: 0, Character: 19}, "users"},
117 {Position{Line: 0, Character: 25}, "WHERE"},
118 {Position{Line: 0, Character: 31}, "active"},
119 {Position{Line: 0, Character: 37}, "true"}, // "true" starts at 37: "SELECT id FROM users WHERE active = true"
120 }
121
122 for _, tt := range tests {
123 word := doc.GetWordAtPosition(tt.pos)
124 if word != tt.expected {
125 t.Errorf("GetWordAtPosition(%v) = %q, want %q", tt.pos, word, tt.expected)
126 }
127 }
128}
129
130func TestHandler_Initialize(t *testing.T) {
131 mock := newMockReadWriter()

Callers

nothing calls this directly

Calls 2

GetWordAtPositionMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected