Debian Codegraph @

td/private_test.go

raw
1 // Copyright (c) 2018-2021, Maxime Soulé
2 // All rights reserved.
3 //
4 // This source code is licensed under the BSD-style license found in the
5 // LICENSE file in the root directory of this source tree.
6
7 package td
8
9 import (
10 "testing"
11
12 "github.com/maxatome/go-testdeep/internal/test"
13 )
14
15 // Edge cases not tested elsewhere...
16
17 func TestBase(t *testing.T) {
18 td := base{}
19
20 td.setLocation(200)
21 if td.location.File != "???" && td.location.Line != 0 {
22 t.Errorf("Location found! => %s", td.location)
23 }
24 }
25
26 func TestTdSetResult(t *testing.T) {
27 if tdSetResultKind(199).String() != "?" {
28 t.Errorf("tdSetResultKind stringification failed => %s",
29 tdSetResultKind(199))
30 }
31 }
32
33 func TestPkgFunc(t *testing.T) {
34 pkg, fn := pkgFunc("package.Foo")
35 test.EqualStr(t, pkg, "package")
36 test.EqualStr(t, fn, "Foo")
37
38 pkg, fn = pkgFunc("the/package.Foo")
39 test.EqualStr(t, pkg, "the/package")
40 test.EqualStr(t, fn, "Foo")
41
42 pkg, fn = pkgFunc("the/package.(*T).Foo")
43 test.EqualStr(t, pkg, "the/package")
44 test.EqualStr(t, fn, "(*T).Foo")
45
46 pkg, fn = pkgFunc("the/package.glob..func1")
47 test.EqualStr(t, pkg, "the/package")
48 test.EqualStr(t, fn, "glob..func1")
49
50 // Theorically not possible, but...
51 pkg, fn = pkgFunc(".Foo")
52 test.EqualStr(t, pkg, "")
53 test.EqualStr(t, fn, "Foo")
54
55 pkg, fn = pkgFunc("no/func")
56 test.EqualStr(t, pkg, "no/func")
57 test.EqualStr(t, fn, "")
58
59 pkg, fn = pkgFunc("no/func.")
60 test.EqualStr(t, pkg, "no/func")
61 test.EqualStr(t, fn, "")
62 }