Debian Codegraph @

helpers/tdutil/name_test.go

raw
1 // Copyright (c) 2019, 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 tdutil_test
8
9 import (
10 "testing"
11
12 "github.com/maxatome/go-testdeep/helpers/tdutil"
13 )
14
15 func TestBuildTestName(t *testing.T) {
16 for i, curTest := range []struct {
17 params []any
18 expected string
19 }{
20 {
21 params: []any{},
22 expected: "",
23 },
24 {
25 params: []any{"foobar"},
26 expected: "foobar",
27 },
28 {
29 params: []any{"foobar %d"},
30 expected: "foobar %d",
31 },
32 {
33 params: []any{"foobar %", 12},
34 expected: "foobar %12",
35 },
36 {
37 params: []any{"foo", "bar"},
38 expected: "foobar",
39 },
40 {
41 params: []any{123, "zip"},
42 expected: "123zip",
43 },
44 {
45 params: []any{123, 456},
46 expected: "123 456",
47 },
48 {
49 params: []any{"foo(%d) bar(%s)", 123, "zip"},
50 expected: "foo(123) bar(zip)",
51 },
52 } {
53 name := tdutil.BuildTestName(curTest.params...)
54 if name != curTest.expected {
55 t.Errorf(`BuildTestName#%d == "%s" but ≠ "%s"`, i, name, curTest.expected)
56 }
57 }
58
59 tdutil.FbuildTestName(nil)
60 }