bool run_tests(const std::vector<std::string>* tests) { std::vector<std::string> all_tests; if(!tests) { for(TestMap::const_iterator i = get_test_map().begin(); i != get_test_map().end(); ++i) { all_tests.push_back(i->first); } tests = &all_tests; } int npass = 0, nfail = 0; foreach(const std::string& test, *tests) { try { get_test_map()[test](); std::cerr << "TEST " << test << " PASSED\n"; ++npass; } catch(failure_exception&) { std::cerr << "TEST " << test << " FAILED!!\n"; ++nfail; } } if(nfail) { std::cerr << npass << " TESTS PASSED, " << nfail << " TESTS FAILED\n"; return false; } else { std::cerr << "ALL " << npass << " TESTS PASSED\n"; return true; } }
bool run_tests(const std::vector<std::string>* tests) { boost::posix_time::ptime mst1 = boost::posix_time::microsec_clock::local_time(); std::vector<std::string> all_tests; if(!tests) { for(test_map::const_iterator i = get_test_map().begin(); i != get_test_map().end(); ++i) { all_tests.push_back(i->first); } tests = &all_tests; } int npass = 0, nfail = 0; BOOST_FOREACH(const std::string& test, *tests) { try { get_test_map()[test](); std::cerr << "TEST " << test << " PASSED\n"; ++npass; } catch(failure_exception&) { std::cerr << "TEST " << test << " FAILED!!\n"; ++nfail; } } if(nfail) { std::cerr << npass << " TESTS PASSED, " << nfail << " TESTS FAILED\n"; return false; } else { boost::posix_time::ptime mst2 = boost::posix_time::microsec_clock::local_time(); boost::posix_time::time_duration msdiff = mst2 - mst1; std::cerr << "ALL " << npass << " TESTS PASSED IN " << msdiff.total_milliseconds() << "ms\n"; return true; } }
bool run_tests(const std::vector<std::string>* tests) { const int start_time = SDL_GetTicks(); std::vector<std::string> all_tests; if(!tests) { for(TestMap::const_iterator i = get_test_map().begin(); i != get_test_map().end(); ++i) { all_tests.push_back(i->first); } tests = &all_tests; } int npass = 0, nfail = 0; foreach(const std::string& test, *tests) { if(preferences::run_failing_unit_tests() == false && test.size() > 5 && std::string(test.end()-5, test.end()) == "FAILS") { continue; } try { get_test_map()[test](); std::cerr << "TEST " << test << " PASSED\n"; ++npass; } catch(failure_exception&) { std::cerr << "TEST " << test << " FAILED!!\n"; ++nfail; // } catch(...) { // std::cerr << "TEST " << test << " FAILED WITH UNKNOWN EXCEPTION!!\n"; // ++nfail; } } if(nfail) { std::cerr << npass << " TESTS PASSED, " << nfail << " TESTS FAILED\n"; return false; } else { std::cerr << "ALL " << npass << " TESTS PASSED IN " << (SDL_GetTicks() - start_time) << "ms\n"; return true; } }