Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2007-10-14 03:38:50


Author: danieljames
Date: 2007-10-14 03:38:49 EDT (Sun, 14 Oct 2007)
New Revision: 40004
URL: http://svn.boost.org/trac/boost/changeset/40004

Log:
Avoid some warnings when compiling the test with Visual C++.

Text files modified:
   trunk/libs/functional/hash/test/hash_float_test.hpp | 7 +++++++
   trunk/libs/functional/hash/test/hash_map_test.hpp | 8 ++++++++
   trunk/libs/functional/hash/test/hash_number_test.cpp | 26 +++++++++++++++++++++++---
   trunk/libs/functional/hash/test/hash_sequence_test.hpp | 9 +++++++++
   trunk/libs/functional/hash/test/hash_set_test.hpp | 9 +++++++++
   5 files changed, 56 insertions(+), 3 deletions(-)

Modified: trunk/libs/functional/hash/test/hash_float_test.hpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_float_test.hpp (original)
+++ trunk/libs/functional/hash/test/hash_float_test.hpp 2007-10-14 03:38:49 EDT (Sun, 14 Oct 2007)
@@ -17,6 +17,10 @@
 #include <boost/limits.hpp>
 
 #include <iostream>
+#if defined(BOOST_MSVC)
+#pragma warning(push)
+#pragma warning(disable:4127) // conditional expression is constant
+#endif
 
 template <class T>
 void float_tests(char const* name, T* = 0)
@@ -198,3 +202,6 @@
 #endif
 }
 
+#if defined(BOOST_MSVC)
+#pragma warning(pop)
+#endif

Modified: trunk/libs/functional/hash/test/hash_map_test.hpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_map_test.hpp (original)
+++ trunk/libs/functional/hash/test/hash_map_test.hpp 2007-10-14 03:38:49 EDT (Sun, 14 Oct 2007)
@@ -8,6 +8,10 @@
 #else
 
 #include <boost/preprocessor/cat.hpp>
+#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 @@
     }
 }
 
+#if defined(BOOST_MSVC)
+#pragma warning(pop)
+#endif
+
 #undef CONTAINER_TYPE
 #endif

Modified: trunk/libs/functional/hash/test/hash_number_test.cpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_number_test.cpp (original)
+++ trunk/libs/functional/hash/test/hash_number_test.cpp 2007-10-14 03:38:49 EDT (Sun, 14 Oct 2007)
@@ -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 <class T>
 void numeric_test(T*)
 {
@@ -31,7 +38,7 @@
     HASH_NAMESPACE::hash<T> x1;
     HASH_NAMESPACE::hash<T> 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 @@
         BOOST_TEST(x1((limits::max)()) != x2((limits::max)() - 1));
 }
 
+void bool_test()
+{
+ HASH_NAMESPACE::hash<bool> x1;
+ HASH_NAMESPACE::hash<bool> 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 @@
 
 int main()
 {
- NUMERIC_TEST(bool, bool)
     NUMERIC_TEST(char, char)
     NUMERIC_TEST(signed char, schar)
     NUMERIC_TEST(unsigned char, uchar)
@@ -142,7 +158,11 @@
     NUMERIC_TEST(double, double)
     NUMERIC_TEST(long double, ldouble)
 
+ bool_test();
+
     return boost::report_errors();
 }
 
-
+#if defined(BOOST_MSVC)
+#pragma warning(pop)
+#endif

Modified: trunk/libs/functional/hash/test/hash_sequence_test.hpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_sequence_test.hpp (original)
+++ trunk/libs/functional/hash/test/hash_sequence_test.hpp 2007-10-14 03:38:49 EDT (Sun, 14 Oct 2007)
@@ -9,6 +9,11 @@
 
 #include <boost/preprocessor/cat.hpp>
 
+#if defined(BOOST_MSVC)
+#pragma warning(push)
+#pragma warning(disable:4245) // signed/unsigned mismatch
+#endif
+
 namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
 {
     template <class T>
@@ -63,5 +68,9 @@
     }
 }
 
+#if defined(BOOST_MSVC)
+#pragma warning(pop)
+#endif
+
 #undef CONTAINER_TYPE
 #endif

Modified: trunk/libs/functional/hash/test/hash_set_test.hpp
==============================================================================
--- trunk/libs/functional/hash/test/hash_set_test.hpp (original)
+++ trunk/libs/functional/hash/test/hash_set_test.hpp 2007-10-14 03:38:49 EDT (Sun, 14 Oct 2007)
@@ -9,6 +9,11 @@
 
 #include <boost/preprocessor/cat.hpp>
 
+#if defined(BOOST_MSVC)
+#pragma warning(push)
+#pragma warning(disable:4245) // signed/unsigned mismatch
+#endif
+
 namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
 {
     template <class T>
@@ -61,5 +66,9 @@
     }
 }
 
+#if defined(BOOST_MSVC)
+#pragma warning(pop)
+#endif
+
 #undef CONTAINER_TYPE
 #endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk