corda/sgx-jvm/avian/unittest/test-harness.cpp

54 lines
1.1 KiB
C++
Raw Normal View History

2015-03-13 18:52:59 +00:00
/* Copyright (c) 2008-2015, Avian Contributors
2013-02-15 03:54:20 +00:00
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
#include <stdio.h>
#include "test-harness.h"
// since we aren't linking against libstdc++, we must implement this
// ourselves:
2014-07-11 15:50:18 +00:00
extern "C" void __cxa_pure_virtual(void)
{
abort();
}
2013-02-15 03:54:20 +00:00
Test* Test::first = 0;
Test** Test::last = &first;
2014-07-11 15:50:18 +00:00
Test::Test(const char* name) : next(0), failures(0), runs(0), name(name)
2013-02-15 03:54:20 +00:00
{
*last = this;
last = &next;
}
2014-07-11 15:50:18 +00:00
bool Test::runAll()
{
2013-02-15 03:54:20 +00:00
int failures = 0;
2014-07-11 15:50:18 +00:00
for (Test* t = Test::first; t; t = t->next) {
printf("%32s: ", t->name);
2013-02-15 03:54:20 +00:00
t->run();
failures += t->failures;
2014-07-11 15:50:18 +00:00
if (t->failures > 0) {
2013-02-15 03:54:20 +00:00
printf("failure\n");
} else {
printf("success\n");
}
}
return failures == 0;
}
2014-07-11 15:50:18 +00:00
int main(int argc UNUSED, char** argv UNUSED)
{
if (Test::runAll()) {
2013-02-15 03:54:20 +00:00
return 0;
}
return 1;
}