diff options
Diffstat (limited to 'internal/lsp/codegen_helpers_test.go')
| -rw-r--r-- | internal/lsp/codegen_helpers_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/lsp/codegen_helpers_test.go b/internal/lsp/codegen_helpers_test.go new file mode 100644 index 0000000..d897953 --- /dev/null +++ b/internal/lsp/codegen_helpers_test.go @@ -0,0 +1,15 @@ +package lsp + +import "testing" + +func TestParseGoPackageName(t *testing.T) { + lines := []string{"// comment", "package mypkg // trailing"} + if got := parseGoPackageName(lines); got != "mypkg" { t.Fatalf("got %q", got) } + if got := parseGoPackageName([]string{"no package"}); got != "" { t.Fatalf("expected empty") } +} + +func TestDeriveGoFuncName(t *testing.T) { + if got := deriveGoFuncName("func Sum(a int) int { return a }"); got != "Sum" { t.Fatalf("got %q", got) } + if got := deriveGoFuncName("func (t *Type) Method(x int) {}"); got != "Method" { t.Fatalf("got %q", got) } +} + |
