From 96ace6c7019a914e21b25fa94ddfc4ee9239c2fb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 18 Aug 2025 09:28:48 +0300 Subject: 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 --- internal/lsp/handlers_test.go | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'internal/lsp/handlers_test.go') 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) { -- cgit v1.2.3