32 lines
733 B
C++
32 lines
733 B
C++
#include "test_main.h"
|
|
|
|
namespace testing {
|
|
|
|
std::vector<Case>& registry() {
|
|
static std::vector<Case> r;
|
|
return r;
|
|
}
|
|
|
|
int& failures() {
|
|
static int n = 0;
|
|
return n;
|
|
}
|
|
|
|
void report_failure(const char* file, int line, const std::string& expr) {
|
|
std::printf(" FAIL %s:%d: %s\n", file, line, expr.c_str());
|
|
++failures();
|
|
}
|
|
|
|
} // namespace testing
|
|
|
|
int main() {
|
|
int ran = 0;
|
|
for (const auto& c : testing::registry()) {
|
|
int before = testing::failures();
|
|
c.fn();
|
|
++ran;
|
|
if (testing::failures() != before) std::printf("[FAILED] %s\n", c.name);
|
|
}
|
|
std::printf("%d unit tests, %d failed assertions\n", ran, testing::failures());
|
|
return testing::failures() ? 1 : 0;
|
|
}
|