diff options
| author | Paul Buetow <paul@buetow.org> | 2025-08-18 09:28:48 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-08-18 09:28:48 +0300 |
| commit | 96ace6c7019a914e21b25fa94ddfc4ee9239c2fb (patch) | |
| tree | 30550bcab30c91e917a4d8b3feccda829a364437 /internal/lsp/handlers_test.go | |
| parent | 6d29ac7e4b2604b5c7df50f33f8ef2357709faf2 (diff) | |
refactor(lsp,llm,hexailsp,appconfig): split long funcs; add tests
- Extract helpers to keep funcs <=50 lines; no behavior changes
- Add tests for prompt removal, code actions, and LLM request builders
- Table-drive TestInParamList; run gofmt
Diffstat (limited to 'internal/lsp/handlers_test.go')
| -rw-r--r-- | internal/lsp/handlers_test.go | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/internal/lsp/handlers_test.go b/internal/lsp/handlers_test.go index 9a490e3..10b704b 100644 --- a/internal/lsp/handlers_test.go +++ b/internal/lsp/handlers_test.go @@ -9,16 +9,26 @@ import ( ) func TestInParamList(t *testing.T) { - line := "func foo(a int, b string) int {" - if !inParamList(line, 15) { // inside params - t.Fatalf("expected inParamList true for cursor inside params") - } - if inParamList(line, 2) { // before 'func' - t.Fatalf("expected inParamList false for cursor before params") - } - if inParamList(line, len(line)) { // after ')' - t.Fatalf("expected inParamList false for cursor after params") - } + line := "func foo(a int, b string) int {" + cases := []struct{ + name string + cursor int + want bool + }{ + {"inside-params", 15, true}, + {"before-func", 2, false}, + {"after-paren", len(line), false}, + {"at-open-paren", strings.Index(line, "(")+1, true}, + {"at-close-paren", strings.Index(line, ")"), true}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + got := inParamList(line, tc.cursor) + if got != tc.want { + t.Fatalf("cursor=%d got %v want %v", tc.cursor, got, tc.want) + } + }) + } } func TestComputeWordStart(t *testing.T) { |
