@@ -32,7 +32,7 @@ function TestEncodeToString(t)
3232 for _ , tt in ipairs (tests ) do
3333 t :Run (tt .name , function (t )
3434 local got = tt .encoder :encode_to_string (tt .input )
35- assert :Equal (t , tt .expected , got )
35+ assert :Equal (t , tt .expected , got )
3636 end )
3737 end
3838end
@@ -68,11 +68,11 @@ function TestDecodeString(t)
6868 t :Run (tt .name , function (t )
6969 local got , err = tt .encoder :decode_string (tt .input )
7070 if tt .want_err then
71- assert ( err , " expected err" )
71+ assert : Error ( t , err )
7272 return
7373 end
74- assert ( not err , err )
75- assert ( tt . expected == got , string.format ( " '%s' ~= '%s' " , tt .expected , got ) )
74+ assert : NoError ( t , err )
75+ assert : Equal ( t , tt .expected , got )
7676 end )
7777 end
7878end
@@ -104,8 +104,8 @@ function TestEncodeDecode(t)
104104 t :Run (tt .name , function (t )
105105 local encoded = tt .encoder :encode_to_string (tt .input )
106106 local decoded , err = tt .encoder :decode_string (encoded )
107- assert ( not err , err )
108- assert ( tt . input == decoded , string.format ( " '%s' ~= '%s' " , tt .input , decoded ) )
107+ assert : NoError ( t , err )
108+ assert : Equal ( t , tt .input , decoded )
109109 end )
110110 end
111111end
@@ -116,42 +116,42 @@ function TestEncoder(t)
116116 encoder :write (" foo" , " bar" , " baz" )
117117 encoder :close ()
118118 local s = writer :string ()
119- assert ( s == " Zm9vYmFyYmF6" , string.format ( " '%s' ~= '%s' " , s , " Zm9vYmFyYmF6 " ) )
119+ assert : Equal ( t , " Zm9vYmFyYmF6" , s )
120120end
121121
122122function TestDecoder (t )
123123 local reader = strings .new_reader (" Zm9vYmFyYmF6" )
124124 local decoder = base64 .new_decoder (base64 .StdEncoding , reader )
125125 local s = decoder :read (" *a" )
126- assert ( s == " foobarbaz" , string.format ( " '%s' ~= '%s' " , s , " foobarbaz " ) )
126+ assert : Equal ( t , " foobarbaz" , s )
127127end
128128
129129function TestDecoderReadNum (t )
130130 local encoded = base64 .StdEncoding :encode_to_string (" 123 456 789" )
131131 local reader = strings .new_reader (encoded )
132132 local decoder = base64 .new_decoder (base64 .StdEncoding , reader )
133133 local n = decoder :read (" *n" )
134- assert ( n == 123 , string.format ( " %d ~= %d " , n , 123 ) )
134+ assert : Equal ( t , 123 , n )
135135 n = decoder :read (" *n" )
136- assert ( n == 456 , string.format ( " %d ~= %d " , n , 456 ) )
136+ assert : Equal ( t , 456 , n )
137137 n = decoder :read (" *n" )
138- assert ( n == 789 , string.format ( " %d ~= %d " , n , 789 ) )
138+ assert : Equal ( t , 789 , n )
139139end
140140
141141function TestDecoderReadCount (t )
142142 local encoded = base64 .StdEncoding :encode_to_string (" 123 456 789" )
143143 local reader = strings .new_reader (encoded )
144144 local decoder = base64 .new_decoder (base64 .StdEncoding , reader )
145145 local s = decoder :read (3 )
146- assert ( s == " 123" , string.format ( " '%s' ~= '%s' " , s , " 123 " ) )
146+ assert : Equal ( t , " 123" , s )
147147end
148148
149149function TestDecoderReadline (t )
150150 local encoded = base64 .StdEncoding :encode_to_string (" foo\n bar" )
151151 local reader = strings .new_reader (encoded )
152152 local decoder = base64 .new_decoder (base64 .StdEncoding , reader )
153153 local s = decoder :read (" *l" )
154- assert ( s == " foo" , string.format ( " '%s' ~= '%s' " , s , " foo " ) )
154+ assert : Equal ( t , " foo" , s )
155155 s = decoder :read (" *l" )
156- assert ( s == " bar" , string.format ( " '%s' ~= '%s' " , s , " bar " ) )
156+ assert : Equal ( t , " bar" , s )
157157end
0 commit comments