...
1 package report
2
3 import (
4 "reflect"
5 "testing"
6 )
7
8 func TestShortNames(t *testing.T) {
9 type testCase struct {
10 name string
11 in string
12 out []string
13 }
14 test := func(name, in string, out ...string) testCase {
15 return testCase{name, in, out}
16 }
17
18 for _, c := range []testCase{
19 test("empty", "", ""),
20 test("simple", "foo", "foo"),
21 test("trailingsep", "foo.bar.", "foo.bar.", "bar."),
22 test("cplusplus", "a::b::c", "a::b::c", "b::c", "c"),
23 test("dotted", "a.b.c", "a.b.c", "b.c", "c"),
24 test("mixed_separators", "a::b.c::d", "a::b.c::d", "b.c::d", "c::d", "d"),
25 test("call_operator", "foo::operator()", "foo::operator()", "operator()"),
26 } {
27 t.Run(c.name, func(t *testing.T) {
28 got := shortNameList(c.in)
29 if !reflect.DeepEqual(c.out, got) {
30 t.Errorf("shortNameList(%q) = %#v, expecting %#v", c.in, got, c.out)
31 }
32 })
33 }
34 }
35
View as plain text