1111#include < sys/time.h>
1212#include < vector>
1313
14- using namespace std ;
15-
1614
1715const static double __EPSILON = 1e-9 ;
1816static double __time = 0.0 ;
@@ -126,11 +124,17 @@ bool __equals(double actual, double expected)
126124bool __equals (const std::vector<double >& actual, const std::vector<double >& expected)
127125{
128126 if (actual.size () != expected.size ())
127+ {
129128 return false ;
129+ }
130130
131131 for (size_t i = 0 ; i < actual.size (); ++i)
132+ {
132133 if (!__equals (actual[i], expected[i]))
134+ {
133135 return false ;
136+ }
137+ }
134138
135139 return true ;
136140}
@@ -144,50 +148,57 @@ int main(int argc, char* argv[])
144148
145149 if (1 < argc) __abort_on_fail = true ;
146150
151+ std::cout << " TAP version 13" << std::endl;
152+ std::cout.flush ();
153+
147154 std::ifstream __in (" testcases.txt" );
148155 for (;;)
149156 {
157+ int __testnum = __pass + __fail + 1 ;
158+
150159 $RETURNTYPE$ __expected;
151160 $METHODPARAMDECLARES$
152161 __in >> __expected >> $METHODPARAMSTREAMIN$;
153162 if (!__in.good ()) break ;
154163
155- std::cout << " ----------------------------------------" << std::endl
156- << " Test " << (__pass + __fail) << " : " ;
164+ std::cout << " # input for test " << __testnum << " : " << $METHODPARAMSTREAMOUT$ << std::endl;
157165 std::cout.flush ();
158166
159167 __timer_start ();
160168
161- $CLASSNAME$ object ;
162- $RETURNTYPE$ __actual = object .$METHODNAME$($METHODPARAMNAMES$);
169+ $CLASSNAME$ __object ;
170+ $RETURNTYPE$ __actual = __object .$METHODNAME$($METHODPARAMNAMES$);
163171
164172 double __t = __timer_stop ();
165173
174+ std::cout << " # test completed in " << __t << " seconds" << std::endl;
175+ std::cout.flush ();
176+
166177 if (__equals (__actual, __expected))
167178 {
168- std::cout << " [PASS] in " << __t << " seconds. " << std::endl ;
179+ std::cout << " ok " ;
169180 ++__pass;
170181 }
171182 else
172183 {
173- std::cout << " [FAIL] in " << __t << " seconds." << std::endl
174- << " -> Input: " << $METHODPARAMSTREAMOUT$ << std::endl
175- << " Actual: " << __actual << std::endl
176- << " Expected: " << __expected << std::endl;
184+ std::cout << " not ok" ;
177185 ++__fail;
178- if (__abort_on_fail) std::abort ();
179186 }
187+
188+ std::cout << " " << __testnum << " - " << __actual << " must equal " << __expected << std::endl;
189+ std::cout.flush ();
190+
191+ if (__abort_on_fail && 0 < __fail) std::abort ();
180192 }
181193
182- std::cout << " ======================================== " << std::endl
183- << " Total Pass : " << __pass << std::endl
184- << " Total Fail : " << __fail << std::endl;
194+ std::cout << " 1.. " << (__pass + __fail) << std::endl
195+ << " # passed : " << __pass << std::endl
196+ << " # failed : " << __fail << std::endl;
185197
186198 if (__fail == 0 )
187199 {
188- std::cout << std::endl << " Nice! "
189- << " Don't forget to compile remotely before submitting."
190- << std::endl;
200+ std::cout << std::endl
201+ << " # Nice! Don't forget to compile remotely before submitting." << std::endl;
191202 }
192203
193204 return __fail;
0 commit comments