(t *testing.T)
| 5 | ) |
| 6 | |
| 7 | func TestPackageName(t *testing.T) { |
| 8 | type testCase struct { |
| 9 | name string |
| 10 | expect string |
| 11 | } |
| 12 | |
| 13 | for _, c := range []testCase{ |
| 14 | // Unrecognized packages: |
| 15 | {``, ``}, |
| 16 | {`name`, ``}, |
| 17 | {`[libjvm.so]`, ``}, |
| 18 | {`prefix/name/suffix`, ``}, |
| 19 | {`prefix(a.b.c,x.y.z)`, ``}, |
| 20 | {`<undefined>.a.b`, ``}, |
| 21 | {`(a.b)`, ``}, |
| 22 | |
| 23 | // C++ symbols: |
| 24 | {`Math.number`, `Math`}, |
| 25 | {`std::vector`, `std`}, |
| 26 | {`std::internal::vector`, `std`}, |
| 27 | |
| 28 | // Java symbols: |
| 29 | {`pkg.Class.name`, `pkg`}, |
| 30 | {`pkg.pkg.Class.name`, `pkg`}, |
| 31 | {`pkg.Class.name(a.b.c, x.y.z)`, `pkg`}, |
| 32 | {`pkg.pkg.Class.<init>`, `pkg`}, |
| 33 | {`pkg.pkg.Class.<init>(a.b.c, x.y.z)`, `pkg`}, |
| 34 | |
| 35 | // Go symbols: |
| 36 | {`pkg.name`, `pkg`}, |
| 37 | {`pkg.(*type).name`, `pkg`}, |
| 38 | {`path/pkg.name`, `path/pkg`}, |
| 39 | {`path/pkg.(*type).name`, `path/pkg`}, |
| 40 | {`path/path/pkg.name`, `path/path/pkg`}, |
| 41 | {`path/path/pkg.(*type).name`, `path/path/pkg`}, |
| 42 | {`some.url.com/path/pkg.fnID`, `some.url.com/path/pkg`}, |
| 43 | {`parent-dir/dir/google.golang.org/grpc/transport.NewFramer`, `parent-dir/dir/google.golang.org/grpc/transport`}, |
| 44 | {`parent-dir/dir/google.golang.org/grpc.(*Server).handleRawConn`, `parent-dir/dir/google.golang.org/grpc`}, |
| 45 | } { |
| 46 | t.Run(c.name, func(t *testing.T) { |
| 47 | if got := packageName(c.name); got != c.expect { |
| 48 | t.Errorf("packageName(%q) = %#v, expecting %#v", c.name, got, c.expect) |
| 49 | } |
| 50 | }) |
| 51 | } |
| 52 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…