MCPcopy
hub / github.com/grpc/grpc-go / TestLoggerV2PrintFuncAllCombinations

Function TestLoggerV2PrintFuncAllCombinations

grpclog/internal/loggerv2_test.go:210–307  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

208}
209
210func TestLoggerV2PrintFuncAllCombinations(t *testing.T) {
211 const (
212 print int = iota
213 printf
214 println
215 )
216
217 type testDiscard struct {
218 discardInf bool
219 discardWarn bool
220 discardErr bool
221
222 printType int
223 formatJSON bool
224 }
225
226 discardName := func(td testDiscard) string {
227 strs := []string{}
228 if td.discardInf {
229 strs = append(strs, "discardInfo")
230 }
231 if td.discardWarn {
232 strs = append(strs, "discardWarn")
233 }
234 if td.discardErr {
235 strs = append(strs, "discardErr")
236 }
237 if len(strs) == 0 {
238 strs = append(strs, "noDiscard")
239 }
240 return strings.Join(strs, " ")
241 }
242 var printName = []string{
243 print: "print",
244 printf: "printf",
245 println: "println",
246 }
247 var jsonName = map[bool]string{
248 true: "json",
249 false: "noJson",
250 }
251
252 discardTests := []testDiscard{}
253 for _, di := range []bool{true, false} {
254 for _, dw := range []bool{true, false} {
255 for _, de := range []bool{true, false} {
256 for _, pt := range []int{print, printf, println} {
257 for _, fj := range []bool{true, false} {
258 discardTests = append(discardTests, testDiscard{discardInf: di, discardWarn: dw, discardErr: de, printType: pt, formatJSON: fj})
259 }
260 }
261 }
262 }
263 }
264
265 for _, discardTest := range discardTests {
266 testName := fmt.Sprintf("%v %v %v", jsonName[discardTest.formatJSON], printName[discardTest.printType], discardName(discardTest))
267 t.Run(testName, func(t *testing.T) {

Callers

nothing calls this directly

Calls 12

InfoMethod · 0.95
WarningMethod · 0.95
ErrorMethod · 0.95
InfofMethod · 0.95
WarningfMethod · 0.95
ErrorfMethod · 0.95
InfolnMethod · 0.95
WarninglnMethod · 0.95
ErrorlnMethod · 0.95
JoinMethod · 0.80
NewLoggerV2Function · 0.70

Tested by

no test coverage detected