summaryrefslogtreecommitdiff
path: root/internal/lsp/prefix_table_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/lsp/prefix_table_test.go')
-rw-r--r--internal/lsp/prefix_table_test.go24
1 files changed, 24 insertions, 0 deletions
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)
+ }
+ }
+}
+