Source file
src/go/types/errors_test.go
1
2
3
4
5
6
7
8 package types
9
10 import "testing"
11
12 func TestError(t *testing.T) {
13 var err error_
14 want := "no error"
15 if got := err.msg(); got != want {
16 t.Errorf("empty error: got %q, want %q", got, want)
17 }
18
19 want = "foo 42"
20 err.addf(noposn, "foo %d", 42)
21 if got := err.msg(); got != want {
22 t.Errorf("simple error: got %q, want %q", got, want)
23 }
24
25 want = "foo 42\n\tbar 43"
26 err.addf(noposn, "bar %d", 43)
27 if got := err.msg(); got != want {
28 t.Errorf("simple error: got %q, want %q", got, want)
29 }
30 }
31
32 func TestStripAnnotations(t *testing.T) {
33 for _, test := range []struct {
34 in, want string
35 }{
36 {"", ""},
37 {" ", " "},
38 {"foo", "foo"},
39 {"foo₀", "foo"},
40 {"foo(T₀)", "foo(T)"},
41 } {
42 got := stripAnnotations(test.in)
43 if got != test.want {
44 t.Errorf("%q: got %q; want %q", test.in, got, test.want)
45 }
46 }
47 }
48
View as plain text