MCPcopy
hub / github.com/op/go-logging / TestFormatFuncName

Function TestFormatFuncName

format_test.go:84–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestFormatFuncName(t *testing.T) {
85 var tests = []struct {
86 filename string
87 longpkg string
88 shortpkg string
89 longfunc string
90 shortfunc string
91 }{
92 {"",
93 "???",
94 "???",
95 "???",
96 "???"},
97 {"main",
98 "???",
99 "???",
100 "???",
101 "???"},
102 {"main.",
103 "main",
104 "main",
105 "",
106 ""},
107 {"main.main",
108 "main",
109 "main",
110 "main",
111 "main"},
112 {"github.com/op/go-logging.func·001",
113 "github.com/op/go-logging",
114 "go-logging",
115 "func·001",
116 "func·001"},
117 {"github.com/op/go-logging.stringFormatter.Format",
118 "github.com/op/go-logging",
119 "go-logging",
120 "stringFormatter.Format",
121 "Format"},
122 }
123
124 var v string
125 for _, test := range tests {
126 v = formatFuncName(fmtVerbLongpkg, test.filename)
127 if test.longpkg != v {
128 t.Errorf("%s != %s", test.longpkg, v)
129 }
130 v = formatFuncName(fmtVerbShortpkg, test.filename)
131 if test.shortpkg != v {
132 t.Errorf("%s != %s", test.shortpkg, v)
133 }
134 v = formatFuncName(fmtVerbLongfunc, test.filename)
135 if test.longfunc != v {
136 t.Errorf("%s != %s", test.longfunc, v)
137 }
138 v = formatFuncName(fmtVerbShortfunc, test.filename)
139 if test.shortfunc != v {
140 t.Errorf("%s != %s", test.shortfunc, v)
141 }

Callers

nothing calls this directly

Calls 2

formatFuncNameFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected