From bf53cf2a673af254d7a08bc3b2ab815a08f66117 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 4 Sep 2025 16:04:58 +0300 Subject: tests: add shared test fixtures, expand provider breadth (multi-choice, error bodies), add LSP rewrite/diagnostics realism and table-driven tests --- internal/lsp/prefix_table_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 internal/lsp/prefix_table_test.go (limited to 'internal/lsp/prefix_table_test.go') diff --git a/internal/lsp/prefix_table_test.go b/internal/lsp/prefix_table_test.go new file mode 100644 index 0000000..0ca23d2 --- /dev/null +++ b/internal/lsp/prefix_table_test.go @@ -0,0 +1,24 @@ +package lsp + +import "testing" + +func TestPrefixStripping_Table(t *testing.T) { + cases := []struct{ name, prefix, sugg, want string }{ + {"assign_walrus", "name := ", "name := compute()", "compute()"}, + {"assign_equals", "x = ", "x = y+1", "y+1"}, + {"general_db", "db.", "db.Query()", "Query()"}, + {"general_func", "func New ", "func New() *T", "() *T"}, + } + for _, c := range cases { + var got string + if c.name == "assign_walrus" || c.name == "assign_equals" { + got = stripDuplicateAssignmentPrefix(c.prefix, c.sugg) + } else { + got = stripDuplicateGeneralPrefix(c.prefix, c.sugg) + } + if got != c.want { + t.Fatalf("%s: got %q want %q", c.name, got, c.want) + } + } +} + -- cgit v1.2.3