#include <sys/time.h>
#include <vector>
-using namespace std;
-
const static double __EPSILON = 1e-9;
static double __time = 0.0;
bool __equals(const std::vector<double>& actual, const std::vector<double>& expected)
{
if (actual.size() != expected.size())
+ {
return false;
+ }
for (size_t i = 0; i < actual.size(); ++i)
+ {
if (!__equals(actual[i], expected[i]))
+ {
return false;
+ }
+ }
return true;
}
int main(int argc, char* argv[])
{
- bool __exit_on_fail = false;
+ bool __abort_on_fail = false;
int __pass = 0;
int __fail = 0;
- if (1 < argc) __exit_on_fail = true;
+ if (1 < argc) __abort_on_fail = true;
+
+ std::cout << "TAP version 13" << std::endl;
+ std::cout.flush();
std::ifstream __in("testcases.txt");
for(;;)
{
+ int __testnum = __pass + __fail + 1;
+
$RETURNTYPE$ __expected;
$METHODPARAMDECLARES$
__in >> __expected >> $METHODPARAMSTREAMIN$;
if (!__in.good()) break;
- std::cout << "----------------------------------------" << std::endl
- << "Test " << (__pass + __fail) << ": ";
+ std::cout << "# input for test " << __testnum << ": " << $METHODPARAMSTREAMOUT$ << std::endl;
std::cout.flush();
__timer_start();
- $CLASSNAME$ object;
- $RETURNTYPE$ __actual = object.$METHODNAME$($METHODPARAMNAMES$);
+ $CLASSNAME$ __object;
+ $RETURNTYPE$ __actual = __object.$METHODNAME$($METHODPARAMNAMES$);
double __t = __timer_stop();
+ std::cout << "# test completed in " << __t << " seconds" << std::endl;
+ std::cout.flush();
+
if (__equals(__actual, __expected))
{
- std::cout << "[PASS] in " << __t << " seconds." << std::endl;
+ std::cout << "ok";
++__pass;
}
else
{
- std::cout << "[FAIL] in " << __t << " seconds." << std::endl
- << "-> Input: " << $METHODPARAMSTREAMOUT$ << std::endl
- << " Actual: " << __actual << std::endl
- << " Expected: " << __expected << std::endl;
+ std::cout << "not ok";
++__fail;
- if (__exit_on_fail) exit(1);
}
+
+ std::cout << " " << __testnum << " - " << __actual << " must equal " << __expected << std::endl;
+ std::cout.flush();
+
+ if (__abort_on_fail && 0 < __fail) std::abort();
}
- std::cout << "========================================" << std::endl
- << " Total Pass: " << __pass << std::endl
- << " Total Fail: " << __fail << std::endl;
+ std::cout << "1.." << (__pass + __fail) << std::endl
+ << "# passed: " << __pass << std::endl
+ << "# failed: " << __fail << std::endl;
if (__fail == 0)
{
- std::cout << std::endl << "Nice! "
- << "Don't forget to compile remotely before submitting."
- << std::endl;
+ std::cout << std::endl
+ << "# Nice! Don't forget to compile remotely before submitting." << std::endl;
}
return __fail;
}
+// vim:ft=cpp:noet:ts=8