From a5439500f50971772a0e301e6d1e13a8536036df Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 12 Feb 2006 18:58:08 +0000 Subject: [PATCH] Remove dead code, use Boost.Test rather than asserts. [SVN r32861] --- call_traits_test.cpp | 83 ++++++-------------------------------------- 1 file changed, 11 insertions(+), 72 deletions(-) diff --git a/call_traits_test.cpp b/call_traits_test.cpp index f5ac3a2..e73ede7 100644 --- a/call_traits_test.cpp +++ b/call_traits_test.cpp @@ -12,7 +12,6 @@ // 03 Oct 2000: // Enabled extra tests for VC6. -#include #include #include #include @@ -22,40 +21,6 @@ #include #include -// -// define tests here -unsigned failures = 0; -unsigned test_count = 0; -// -// This must get defined within the test file. -// All compilers have bugs, set this to the number of -// regressions *expected* from a given compiler, -// if there are no workarounds for the bugs, *and* -// the regressions have been investigated. -// -extern unsigned int expected_failures; -// -// proc check_result() -// Checks that there were no regressions: -// -int check_result(int argc, char** argv) -{ - std::cout << test_count << " tests completed, " - << failures << " failures found, " - << expected_failures << " failures expected from this compiler." << std::endl; - if((argc == 2) - && (argv[1][0] == '-') - && (argv[1][1] == 'a') - && (argv[1][2] == 0)) - { - std::cout << "Press any key to continue..."; - std::cin.get(); - } - return (failures == expected_failures) - ? 0 - : (failures != 0) ? static_cast(failures) : -1; -} - // a way prevent warnings for unused variables template inline void unused_variable(const T&) {} @@ -156,9 +121,9 @@ void call_traits_checker::operator()(param_type p) T t(p); contained c(t); cout << "checking contained<" << typeid(T).name() << ">..." << endl; - assert(t == c.value()); - assert(t == c.get()); - assert(t == c.const_get()); + BOOST_CHECK(t == c.value()); + BOOST_CHECK(t == c.get()); + BOOST_CHECK(t == c.const_get()); #ifndef __ICL //cout << "typeof contained<" << typeid(T).name() << ">::v_ is: " << typeid(&contained::v_).name() << endl; cout << "typeof contained<" << typeid(T).name() << ">::value() is: " << typeid(&contained::value).name() << endl; @@ -180,11 +145,11 @@ struct call_traits_checker cout << "checking contained<" << typeid(T[N]).name() << ">..." << endl; unsigned int i = 0; for(i = 0; i < N; ++i) - assert(t[i] == c.value()[i]); + BOOST_CHECK(t[i] == c.value()[i]); for(i = 0; i < N; ++i) - assert(t[i] == c.get()[i]); + BOOST_CHECK(t[i] == c.get()[i]); for(i = 0; i < N; ++i) - assert(t[i] == c.const_get()[i]); + BOOST_CHECK(t[i] == c.const_get()[i]); cout << "typeof contained<" << typeid(T[N]).name() << ">::v_ is: " << typeid(&contained::v_).name() << endl; cout << "typeof contained<" << typeid(T[N]).name() << ">::value is: " << typeid(&contained::value).name() << endl; @@ -202,7 +167,7 @@ template void check_wrap(const W& w, const U& u) { cout << "checking " << typeid(W).name() << "..." << endl; - assert(w.value() == u); + BOOST_CHECK(w.value() == u); } // @@ -213,8 +178,8 @@ template void check_make_pair(T c, U u, V v) { cout << "checking std::pair<" << typeid(c.first).name() << ", " << typeid(c.second).name() << ">..." << endl; - assert(c.first == u); - assert(c.second == v); + BOOST_CHECK(c.first == u); + BOOST_CHECK(c.second == v); cout << endl; } @@ -290,8 +255,6 @@ int main(int argc, char *argv[ ]) BOOST_CHECK_TYPE(int&, boost::call_traits::param_type); #else std::cout << "Your compiler cannot instantiate call_traits, skipping four tests (4 errors)" << std::endl; - failures += 4; - test_count += 4; #endif BOOST_CHECK_TYPE(const int&, boost::call_traits::value_type); BOOST_CHECK_TYPE(const int&, boost::call_traits::reference); @@ -313,13 +276,9 @@ int main(int argc, char *argv[ ]) BOOST_CHECK_TYPE(const test_abc1&, boost::call_traits::param_type); #else std::cout << "You're compiler does not support partial template specialiation, skipping 8 tests (8 errors)" << std::endl; - failures += 12; - test_count += 12; #endif #else std::cout << "You're compiler does not support partial template specialiation, skipping 20 tests (20 errors)" << std::endl; - failures += 24; - test_count += 24; #endif // test with an incomplete type: BOOST_CHECK_TYPE(incomplete_type, boost::call_traits::value_type); @@ -327,12 +286,12 @@ int main(int argc, char *argv[ ]) BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits::const_reference); BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits::param_type); - return check_result(argc, argv); + return 0; } // // define call_traits tests to check that the assertions in the docs do actually work -// this is an instantiate only set of tests: +// this is an compile-time only set of tests: // template struct call_traits_test @@ -444,23 +403,3 @@ template struct call_traits_test; #endif #endif -#if defined(BOOST_MSVC) && _MSC_VER <= 1300 -unsigned int expected_failures = 12; -#elif defined(__SUNPRO_CC) -#if(__SUNPRO_CC <= 0x520) -unsigned int expected_failures = 18; -#elif(__SUNPRO_CC < 0x530) -unsigned int expected_failures = 17; -#else -unsigned int expected_failures = 6; -#endif -#elif defined(__BORLANDC__) -unsigned int expected_failures = 2; -#elif (defined(__GNUC__) && ((__GNUC__ < 3) || (__GNUC__ == 3) && (__GNUC_MINOR__ < 1))) -unsigned int expected_failures = 4; -#elif defined(__HP_aCC) -unsigned int expected_failures = 24; -#else -unsigned int expected_failures = 0; -#endif -