diff options
author | Zofia Abramowska <z.abramowska@samsung.com> | 2017-04-19 14:09:13 +0200 |
---|---|---|
committer | Tomasz Swierczek <t.swierczek@samsung.com> | 2017-05-16 06:30:25 +0000 |
commit | 1f7531df3939822330e63f3a9d65517b9e4f8a99 (patch) | |
tree | d7a4aa1eca61b6ed08949d3189673bdcb290f1f6 /tests | |
parent | 114e99f1178250cdde4f916563a8f1d99a9411db (diff) | |
download | key-manager-1f7531df3939822330e63f3a9d65517b9e4f8a99.tar.gz key-manager-1f7531df3939822330e63f3a9d65517b9e4f8a99.tar.bz2 key-manager-1f7531df3939822330e63f3a9d65517b9e4f8a99.zip |
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: If4032191c662d365571d961d87a97ff88658778e
Diffstat (limited to 'tests')
-rw-r--r-- | tests/colour_log_formatter.cpp | 81 | ||||
-rw-r--r-- | tests/colour_log_formatter.h | 11 | ||||
-rw-r--r-- | tests/main.cpp | 6 | ||||
-rw-r--r-- | tests/test_sql.cpp | 2 |
4 files changed, 83 insertions, 17 deletions
diff --git a/tests/colour_log_formatter.cpp b/tests/colour_log_formatter.cpp index efcb408b..8a112a2f 100644 --- a/tests/colour_log_formatter.cpp +++ b/tests/colour_log_formatter.cpp @@ -14,7 +14,12 @@ */ // Boost.Test #include <colour_log_formatter.h> +#include <boost/test/impl/execution_monitor.ipp> +#if BOOST_VERSION >= 105900 +#include <boost/test/tree/test_unit.hpp> +#else #include <boost/test/unit_test_suite_impl.hpp> +#endif #include <boost/test/framework.hpp> #include <boost/test/utils/basic_cstring/io.hpp> #include <boost/test/utils/lazy_ostream.hpp> @@ -38,11 +43,29 @@ namespace CKM { 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,13 +128,14 @@ 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; + } //____________________________________________________________________________// @@ -116,8 +146,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 << "\"" << + if (test_unit_type_name_contains(tu, "suite")) { + output << "Finished test " << test_unit_type_name(tu) << " \"" << test_unit_name(tu) << "\"" << std::endl; return; } @@ -156,14 +186,14 @@ colour_log_formatter::test_unit_skipped( std::ostream &output, test_unit const &tu) { - output << "Test " << tu.p_type_name << " \"" << tu.p_name << "\"" << + 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) @@ -195,6 +225,14 @@ colour_log_formatter::log_exception( //____________________________________________________________________________// void +colour_log_formatter::log_exception_finish(std::ostream &os) +{ + (void)os; +} + +//____________________________________________________________________________// + +void colour_log_formatter::log_entry_start( std::ostream &output, log_entry_data const &entry_data, @@ -267,6 +305,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 CKM diff --git a/tests/colour_log_formatter.h b/tests/colour_log_formatter.h index 3c5dae00..d165004d 100644 --- a/tests/colour_log_formatter.h +++ b/tests/colour_log_formatter.h @@ -37,10 +37,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 &, @@ -54,6 +55,14 @@ public: 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 c3ff1ebd..bfafe9c0 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -74,7 +74,7 @@ struct LogSetup { ~LogSetup() {} }; -BOOST_GLOBAL_FIXTURE(KeyProviderLib) -BOOST_GLOBAL_FIXTURE(TestConfig) -BOOST_GLOBAL_FIXTURE(LogSetup) +BOOST_GLOBAL_FIXTURE(KeyProviderLib); +BOOST_GLOBAL_FIXTURE(TestConfig); +BOOST_GLOBAL_FIXTURE(LogSetup); diff --git a/tests/test_sql.cpp b/tests/test_sql.cpp index 6b2a7a67..8fac9c17 100644 --- a/tests/test_sql.cpp +++ b/tests/test_sql.cpp @@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(sqlTestConnectionEncryptedNegative) SqlConnection::DataCommandUniquePtr selectCommand; BOOST_REQUIRE_THROW(selectCommand = encrypting_you.PrepareDataCommand( select_table), - SqlConnection::Exception::SyntaxError) + SqlConnection::Exception::SyntaxError); } } |