9
9
"github.com/stretchr/testify/require"
10
10
)
11
11
12
- const msg = "test case %d failed"
13
-
14
12
var testCasesUnquote = []struct {
15
13
quoted string
16
14
unquoted string
@@ -29,29 +27,33 @@ var testCasesUnquote = []struct {
29
27
}
30
28
31
29
func TestUnquoteSingle (t * testing.T ) {
32
- for i , test := range testCasesUnquote {
33
- s , err := unquoteSingle (test .quoted )
34
- require .NoError (t , err , msg , i )
35
- require .Equal (t , test .unquoted , s , msg , i )
30
+ for _ , test := range testCasesUnquote {
31
+ t .Run ("" , func (t * testing.T ) {
32
+ s , err := unquoteSingle (test .quoted )
33
+ require .NoError (t , err )
34
+ require .Equal (t , test .unquoted , s )
35
+ })
36
36
}
37
37
}
38
38
39
39
func TestUnquoteSingleAndQuoteBack (t * testing.T ) {
40
- for i , test := range testCasesUnquote {
41
- u , err := unquoteSingle (test .quoted )
42
- require .NoError (t , err , msg , i )
43
-
44
- q := quoteSingle (u )
45
- if test .canonicalQuoted != "" {
46
- assertEquals (t , test .canonicalQuoted , q , i )
47
- } else {
48
- assertEquals (t , test .quoted , q , i )
49
- }
40
+ for _ , test := range testCasesUnquote {
41
+ t .Run ("" , func (t * testing.T ) {
42
+ u , err := unquoteSingle (test .quoted )
43
+ require .NoError (t , err )
44
+
45
+ q := quoteSingle (u )
46
+ if test .canonicalQuoted != "" {
47
+ assertEquals (t , test .canonicalQuoted , q )
48
+ } else {
49
+ assertEquals (t , test .quoted , q )
50
+ }
51
+ })
50
52
}
51
53
}
52
54
53
- func assertEquals (t * testing.T , quoted , actual string , i int ) {
54
- if ! assert .Equal (t , quoted , actual , msg , i ) {
55
+ func assertEquals (t * testing.T , quoted , actual string ) {
56
+ if ! assert .Equal (t , quoted , actual ) {
55
57
printDebug (t , quoted , actual )
56
58
t .FailNow ()
57
59
}
0 commit comments