From 8288363a7b432ba0ae0628fc7acf360a17a7f1f3 Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Tue, 25 Apr 2017 15:54:30 +0200 Subject: Adjust tests to boost 1.62 * Fix missing file * Fix missing virtual methods * Fix missing semicolons after macros * Support boost version before 1.59 Change-Id: I56320f068b74d0ec749e963688be9a58631fa02c --- tests/colour_log_formatter.cpp | 74 ++++++++++++++++++++++++++++++++++++------ tests/colour_log_formatter.h | 11 ++++++- tests/main.cpp | 2 +- 3 files changed, 75 insertions(+), 12 deletions(-) diff --git a/tests/colour_log_formatter.cpp b/tests/colour_log_formatter.cpp index 1d185bc..020ee27 100644 --- a/tests/colour_log_formatter.cpp +++ b/tests/colour_log_formatter.cpp @@ -14,7 +14,12 @@ */ // Boost.Test #include +#include +#if BOOST_VERSION >= 105900 +#include +#else #include +#endif #include #include #include @@ -37,12 +42,30 @@ namespace CCHECKER { namespace { +const_string +test_unit_type_name(const test_unit &tu) +{ +#if BOOST_VERSION >= 105900 + return const_string(tu.p_type_name); +#else + return tu.p_type_name.get(); +#endif +} + +const_string +test_unit_name(const test_unit &tu) +{ +#if BOOST_VERSION >= 105900 + return const_string(tu.p_name); +#else + return tu.p_name.get(); +#endif +} + const_string test_phase_identifier() { - return framework::is_initialized() - ? const_string(framework::current_test_case().p_name.get()) - : BOOST_TEST_L("Test setup"); + return test_unit_name(framework::current_test_case()); } const_string @@ -57,6 +80,12 @@ get_basename(const std::string &file_name) return basename(file_name.c_str()); } +bool +test_unit_type_name_contains(const test_unit &tu, const std::string &substr) +{ + return test_unit_type_name(tu).find(const_string(substr)) == 0; +} + } // local namespace //____________________________________________________________________________// @@ -99,11 +128,12 @@ colour_log_formatter::test_unit_start( std::ostream &output, test_unit const &tu) { - if (tu.p_type_name->find(const_string("suite")) == 0) { - output << "Starting test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl; + if (test_unit_type_name_contains(tu, "suite")) { + output << "Starting test "; } else { - output << "Running test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl; + output << "Running test "; } + output << test_unit_type_name(tu) << " \"" << test_unit_name(tu) << "\"" << std::endl; } //____________________________________________________________________________// @@ -114,8 +144,8 @@ colour_log_formatter::test_unit_finish( test_unit const &tu, unsigned long elapsed) { - if (tu.p_type_name->find(const_string("suite")) == 0) { - output << "Finished test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl; + if (test_unit_type_name_contains(tu, "suite")) { + output << "Finished test " << test_unit_type_name(tu) << " \"" << test_unit_name(tu) << "\"" << std::endl; return; } @@ -150,13 +180,13 @@ colour_log_formatter::test_unit_skipped( std::ostream &output, test_unit const &tu) { - output << "Test " << tu.p_type_name << " \"" << tu.p_name << "\"" << "is skipped" << std::endl; + output << "Test " << test_unit_type_name(tu) << " \"" << test_unit_name(tu) << "\"" << "is skipped" << std::endl; } //____________________________________________________________________________// void -colour_log_formatter::log_exception( +colour_log_formatter::log_exception_start( std::ostream &output, log_checkpoint_data const &checkpoint_data, boost::execution_exception const &ex) @@ -181,6 +211,11 @@ colour_log_formatter::log_exception( m_isTestCaseFailed = true; } +void +colour_log_formatter::log_exception_finish(std::ostream &os) +{ + (void)os; +} //____________________________________________________________________________// void @@ -252,6 +287,25 @@ colour_log_formatter::log_entry_finish( //____________________________________________________________________________// +void +colour_log_formatter::entry_context_start(std::ostream& os, boost::unit_test::log_level l) +{ + (void)os; + (void)l; +} +void +colour_log_formatter::log_entry_context(std::ostream& os, boost::unit_test::const_string value) +{ + (void)os; + (void)value; +} +void +colour_log_formatter::entry_context_finish(std::ostream& os) +{ + (void)os; +} +//____________________________________________________________________________// + //____________________________________________________________________________// } // namespace CCHECKER diff --git a/tests/colour_log_formatter.h b/tests/colour_log_formatter.h index ac4b07f..0838cce 100644 --- a/tests/colour_log_formatter.h +++ b/tests/colour_log_formatter.h @@ -39,10 +39,11 @@ public: std::ostream &, boost::unit_test::test_unit const &tu); - void log_exception( + void log_exception_start( std::ostream &, boost::unit_test::log_checkpoint_data const &, boost::execution_exception const &ex); + void log_exception_finish(std::ostream &os); void log_entry_start( std::ostream &, @@ -55,6 +56,14 @@ public: std::ostream &, boost::unit_test::lazy_ostream const &value); void log_entry_finish(std::ostream &); + + void entry_context_start( + std::ostream& os, + boost::unit_test::log_level l); + void log_entry_context( + std::ostream& os, + boost::unit_test::const_string value); + void entry_context_finish(std::ostream& os); private: bool m_isTestCaseFailed; }; diff --git a/tests/main.cpp b/tests/main.cpp index 59e8df2..9cb2141 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -37,5 +37,5 @@ struct TestConfig { } }; -BOOST_GLOBAL_FIXTURE(TestConfig) +BOOST_GLOBAL_FIXTURE(TestConfig); -- cgit v1.2.3