blob: de43b7d7c81fbe84e4a2c656abfc404468b95b17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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)
}
}
|