From 09b33e65d92f5fb5b907e49c3d27584615cf2b83 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 4 Sep 2025 16:10:01 +0300 Subject: tests: add negative SSE test, table-driven refactors, and use shared fixtures across tests; update REPORT.md progress --- internal/lsp/code_fences_table_test.go | 32 ++++++++++++++++++++++++++++++++ internal/lsp/label_filter_table_test.go | 17 +++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 internal/lsp/code_fences_table_test.go create mode 100644 internal/lsp/label_filter_table_test.go (limited to 'internal/lsp') diff --git a/internal/lsp/code_fences_table_test.go b/internal/lsp/code_fences_table_test.go new file mode 100644 index 0000000..c217bce --- /dev/null +++ b/internal/lsp/code_fences_table_test.go @@ -0,0 +1,32 @@ +package lsp + +import "testing" + +func TestStripCodeFences_Table(t *testing.T) { + cases := []struct{ name, in, want string }{ + {"no_fence", "return x", "return x"}, + {"plain_fence", "```\nA\nB\n```", "A\nB"}, + {"lang_fence", "```go\nfmt.Println()\n```", "fmt.Println()"}, + {"spaces", " \n```python\nprint('x')\n```\n ", "print('x')"}, + } + for _, c := range cases { + if got := stripCodeFences(c.in); got != c.want { + t.Fatalf("%s: got %q want %q", c.name, got, c.want) + } + } +} + +func TestStripInlineCodeSpan_Table(t *testing.T) { + cases := []struct{ name, in, want string }{ + {"no_ticks", "text", "text"}, + {"single_span", "Use `foo()` here", "foo()"}, + {"multiple", "`a` + `b`", "a"}, + {"unmatched", "`missing end", "`missing end"}, + } + for _, c := range cases { + if got := stripInlineCodeSpan(c.in); got != c.want { + t.Fatalf("%s: got %q want %q", c.name, got, c.want) + } + } +} + diff --git a/internal/lsp/label_filter_table_test.go b/internal/lsp/label_filter_table_test.go new file mode 100644 index 0000000..c42b0b1 --- /dev/null +++ b/internal/lsp/label_filter_table_test.go @@ -0,0 +1,17 @@ +package lsp + +import "testing" + +func TestLabelForCompletion_Table(t *testing.T) { + cases := []struct{ cleaned, filter, want string }{ + {"line one\nline two", "zzz", "zzz"}, + {"result", "re", "result"}, + {"hello world", "he", "hello world"}, + } + for _, c := range cases { + if got := labelForCompletion(c.cleaned, c.filter); got != c.want { + t.Fatalf("cleaned=%q filter=%q got %q want %q", c.cleaned, c.filter, got, c.want) + } + } +} + -- cgit v1.2.3