ScopedPointer <UnitTest::Suite>& UnitTest::run ( UnitTests* const runner) { bassert (runner != nullptr); m_runner = runner; m_random = m_runner->m_random; m_suite = new Suite (m_className, m_packageName); initialise(); #if 0 try { runTest(); } catch (...) { failException (); } #else runTest (); #endif shutdown(); finishCase (); m_suite->secondsElapsed = RelativeTime ( Time::getCurrentTime () - m_suite->whenStarted).inSeconds (); return m_suite; }
void test_find_one (Source& root, Source* expected, std::string const& name) { try { Source* source (root.find_one (name)); expect (source == expected); } catch (...) { failException (); } }
void test_find_path (Source& root, std::string const& path, Source* expected) { try { Source* source (root.find_path (path)); expect (source == expected); } catch (...) { failException (); } }
void test_find (Source& root, std::string path, Source* expected, bool expected_star) { try { auto const result (root.find (path)); expect (result.first == expected); expect (result.second == expected_star); } catch (...) { failException (); } }
void test_peel_trailing_slashstar (std::string s, std::string const& expected_remainder, bool should_be_found) { try { bool const found (Source::peel_trailing_slashstar (&s)); expect (found == should_be_found); expect (s == expected_remainder); } catch (...) { failException (); } }
void test_peel_leading_slash (std::string s, std::string const& expected, bool should_be_found) { try { bool const found (Source::peel_leading_slash (&s)); expect (found == should_be_found); expect (s == expected); } catch(...) { failException (); } }
void test_peel_name (std::string s, std::string const& expected, std::string const& expected_remainder) { try { std::string const peeled_name = Source::peel_name (&s); expect (peeled_name == expected); expect (s == expected_remainder); } catch (...) { failException (); } }