From 2196f0ea17f0df085e5fc700f9160e33cc3e8553 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 14 Oct 2007 07:38:49 +0000 Subject: [PATCH] Avoid some warnings when compiling the test with Visual C++. [SVN r40004] --- hash/test/hash_float_test.hpp | 7 +++++++ hash/test/hash_map_test.hpp | 8 ++++++++ hash/test/hash_number_test.cpp | 26 +++++++++++++++++++++++--- hash/test/hash_sequence_test.hpp | 9 +++++++++ hash/test/hash_set_test.hpp | 9 +++++++++ 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/hash/test/hash_float_test.hpp b/hash/test/hash_float_test.hpp index 4c0a431..78d12c6 100644 --- a/hash/test/hash_float_test.hpp +++ b/hash/test/hash_float_test.hpp @@ -17,6 +17,10 @@ #include #include +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4127) // conditional expression is constant +#endif template void float_tests(char const* name, T* = 0) @@ -198,3 +202,6 @@ void float_tests(char const* name, T* = 0) #endif } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif diff --git a/hash/test/hash_map_test.hpp b/hash/test/hash_map_test.hpp index 77cae73..31723d5 100644 --- a/hash/test/hash_map_test.hpp +++ b/hash/test/hash_map_test.hpp @@ -8,6 +8,10 @@ #else #include +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4245) // signed/unsigned mismatch +#endif namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) { @@ -60,5 +64,9 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + #undef CONTAINER_TYPE #endif diff --git a/hash/test/hash_number_test.cpp b/hash/test/hash_number_test.cpp index 66448e8..ae368b1 100644 --- a/hash/test/hash_number_test.cpp +++ b/hash/test/hash_number_test.cpp @@ -21,6 +21,13 @@ #include "./compile_time.hpp" +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4127) // conditional expression is constant +#pragma warning(disable:4309) // truncation of constant value +#pragma warning(disable:4310) // cast truncates constant value +#endif + template void numeric_test(T*) { @@ -31,7 +38,7 @@ void numeric_test(T*) HASH_NAMESPACE::hash x1; HASH_NAMESPACE::hash x2; - T v1 = -5; + T v1 = (T) -5; BOOST_TEST(x1(v1) == x2(v1)); BOOST_TEST(x1(T(-5)) == x2(T(-5))); BOOST_TEST(x1(T(0)) == x2(T(0))); @@ -106,6 +113,16 @@ void poor_quality_tests(T*) BOOST_TEST(x1((limits::max)()) != x2((limits::max)() - 1)); } +void bool_test() +{ + HASH_NAMESPACE::hash x1; + HASH_NAMESPACE::hash x2; + + BOOST_TEST(x1(true) == x2(true)); + BOOST_TEST(x1(false) == x2(false)); + BOOST_TEST(x1(true) != x2(false)); + BOOST_TEST(x1(false) != x2(true)); +} #define NUMERIC_TEST(type, name) \ std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \ @@ -119,7 +136,6 @@ void poor_quality_tests(T*) int main() { - NUMERIC_TEST(bool, bool) NUMERIC_TEST(char, char) NUMERIC_TEST(signed char, schar) NUMERIC_TEST(unsigned char, uchar) @@ -142,7 +158,11 @@ int main() NUMERIC_TEST(double, double) NUMERIC_TEST(long double, ldouble) + bool_test(); + return boost::report_errors(); } - +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif diff --git a/hash/test/hash_sequence_test.hpp b/hash/test/hash_sequence_test.hpp index ac96249..eb3295c 100644 --- a/hash/test/hash_sequence_test.hpp +++ b/hash/test/hash_sequence_test.hpp @@ -9,6 +9,11 @@ #include +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4245) // signed/unsigned mismatch +#endif + namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) { template @@ -63,5 +68,9 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + #undef CONTAINER_TYPE #endif diff --git a/hash/test/hash_set_test.hpp b/hash/test/hash_set_test.hpp index 5ec25ce..7eda536 100644 --- a/hash/test/hash_set_test.hpp +++ b/hash/test/hash_set_test.hpp @@ -9,6 +9,11 @@ #include +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4245) // signed/unsigned mismatch +#endif + namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) { template @@ -61,5 +66,9 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + #undef CONTAINER_TYPE #endif