diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-06 13:18:21 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-06 13:18:21 +0300 |
| commit | 5e966f50111adf6e2cb2683fe588f6fe033fa931 (patch) | |
| tree | 19ac2033483c2ac6147e8f44ac37f14e6a5c0cf7 /internal/lsp/completion_messages_test.go | |
| parent | 80e61812986573464cd24c4b3ffa605c4003146a (diff) | |
fix unit test coverage
Diffstat (limited to 'internal/lsp/completion_messages_test.go')
| -rw-r--r-- | internal/lsp/completion_messages_test.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/internal/lsp/completion_messages_test.go b/internal/lsp/completion_messages_test.go index 37d4a8d..20aac69 100644 --- a/internal/lsp/completion_messages_test.go +++ b/internal/lsp/completion_messages_test.go @@ -59,15 +59,15 @@ func TestBuildDocString_Contents(t *testing.T) { } func TestBuildCompletionMessages_InParams_UsesParamPrompts(t *testing.T) { - s := newTestServer() - p := CompletionParams{TextDocument: TextDocumentIdentifier{URI: "file:///x"}, Position: Position{Line: 0, Character: 5}} - msgs := s.buildCompletionMessages(false, false, "", true, p, "a", "func f(x)", "c", "func f(x)") - if len(msgs) < 2 || msgs[0].Role != "system" || msgs[1].Role != "user" { - t.Fatalf("unexpected messages") - } - if !contains(msgs[0].Content, "function signatures") || !contains(msgs[1].Content, "parameter list") { - t.Fatalf("unexpected in-params prompts: %#v", msgs) - } + s := newTestServer() + p := CompletionParams{TextDocument: TextDocumentIdentifier{URI: "file:///x"}, Position: Position{Line: 0, Character: 5}} + msgs := s.buildCompletionMessages(false, false, "", true, p, "a", "func f(x)", "c", "func f(x)") + if len(msgs) < 2 || msgs[0].Role != "system" || msgs[1].Role != "user" { + t.Fatalf("unexpected messages") + } + if !contains(msgs[0].Content, "function signatures") || !contains(msgs[1].Content, "parameter list") { + t.Fatalf("unexpected in-params prompts: %#v", msgs) + } } func TestPostProcessCompletion_CodeFencesAndDuplicates(t *testing.T) { @@ -87,6 +87,7 @@ func TestPostProcessCompletion_CodeFencesAndDuplicates(t *testing.T) { func contains(s, sub string) bool { return len(s) >= len(sub) && (s == sub || (len(sub) > 0 && (stringIndex(s, sub) >= 0))) } + func stringIndex(s, sub string) int { return len([]rune(s[:])) - len([]rune(s[:])) + (func() int { return intIndex(s, sub) })() } |
