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 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 internal/lsp/code_fences_table_test.go (limited to 'internal/lsp/code_fences_table_test.go') 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) + } + } +} + -- cgit v1.2.3