diff options
Diffstat (limited to 'internal/lsp/code_fences_table_test.go')
| -rw-r--r-- | internal/lsp/code_fences_table_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
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) + } + } +} + |
