mirror of
https://github.com/boostorg/functional.git
synced 2025-08-02 22:14:28 +02:00
Test the hash library with warning level 4 on Visual C++ - although there's
still one warning for hashing long doubles. [SVN r38647]
This commit is contained in:
@@ -9,6 +9,7 @@ project hash-tests
|
|||||||
: requirements
|
: requirements
|
||||||
<toolset>gcc:<define>_GLIBCXX_DEBUG
|
<toolset>gcc:<define>_GLIBCXX_DEBUG
|
||||||
<toolset>gcc:<cxxflags>-Wsign-promo
|
<toolset>gcc:<cxxflags>-Wsign-promo
|
||||||
|
<toolset>msvc:<cxxflags>/W4
|
||||||
;
|
;
|
||||||
|
|
||||||
test-suite functional/hash
|
test-suite functional/hash
|
||||||
|
@@ -19,11 +19,22 @@
|
|||||||
|
|
||||||
#include <complex>
|
#include <complex>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <boost/limits.hpp>
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:4244) // conversion from 'unsigned long' to 'unsigned short', possible loss of data
|
||||||
|
#pragma warning(disable:4512) // assignment operator could not be generated
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <boost/random/mersenne_twister.hpp>
|
#include <boost/random/mersenne_twister.hpp>
|
||||||
#include <boost/random/uniform_int.hpp>
|
#include <boost/random/uniform_int.hpp>
|
||||||
#include <boost/random/uniform_real.hpp>
|
#include <boost/random/uniform_real.hpp>
|
||||||
#include <boost/random/variate_generator.hpp>
|
#include <boost/random/variate_generator.hpp>
|
||||||
#include <boost/limits.hpp>
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void generic_complex_tests(std::complex<T> v)
|
void generic_complex_tests(std::complex<T> v)
|
||||||
|
@@ -18,6 +18,11 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:4127) // conditional expression is constant
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void float_tests(char const* name, T* = 0)
|
void float_tests(char const* name, T* = 0)
|
||||||
{
|
{
|
||||||
@@ -226,3 +231,6 @@ int main()
|
|||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
@@ -9,6 +9,11 @@
|
|||||||
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#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)
|
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -60,5 +65,9 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef CONTAINER_TYPE
|
#undef CONTAINER_TYPE
|
||||||
#endif
|
#endif
|
||||||
|
@@ -21,6 +21,13 @@
|
|||||||
|
|
||||||
#include "./compile_time.hpp"
|
#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>
|
template <class T>
|
||||||
void numeric_test(T*)
|
void numeric_test(T*)
|
||||||
{
|
{
|
||||||
@@ -31,7 +38,7 @@ void numeric_test(T*)
|
|||||||
HASH_NAMESPACE::hash<T> x1;
|
HASH_NAMESPACE::hash<T> x1;
|
||||||
HASH_NAMESPACE::hash<T> x2;
|
HASH_NAMESPACE::hash<T> x2;
|
||||||
|
|
||||||
T v1 = -5;
|
T v1 = (T) -5;
|
||||||
BOOST_TEST(x1(v1) == x2(v1));
|
BOOST_TEST(x1(v1) == x2(v1));
|
||||||
BOOST_TEST(x1(T(-5)) == x2(T(-5)));
|
BOOST_TEST(x1(T(-5)) == x2(T(-5)));
|
||||||
BOOST_TEST(x1(T(0)) == x2(T(0)));
|
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));
|
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) \
|
#define NUMERIC_TEST(type, name) \
|
||||||
std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \
|
std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \
|
||||||
@@ -119,7 +136,6 @@ void poor_quality_tests(T*)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
NUMERIC_TEST(bool, bool)
|
|
||||||
NUMERIC_TEST(char, char)
|
NUMERIC_TEST(char, char)
|
||||||
NUMERIC_TEST(signed char, schar)
|
NUMERIC_TEST(signed char, schar)
|
||||||
NUMERIC_TEST(unsigned char, uchar)
|
NUMERIC_TEST(unsigned char, uchar)
|
||||||
@@ -142,7 +158,11 @@ int main()
|
|||||||
NUMERIC_TEST(double, double)
|
NUMERIC_TEST(double, double)
|
||||||
NUMERIC_TEST(long double, ldouble)
|
NUMERIC_TEST(long double, ldouble)
|
||||||
|
|
||||||
|
bool_test();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
@@ -9,6 +9,11 @@
|
|||||||
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#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)
|
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -63,5 +68,9 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef CONTAINER_TYPE
|
#undef CONTAINER_TYPE
|
||||||
#endif
|
#endif
|
||||||
|
@@ -9,12 +9,17 @@
|
|||||||
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#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)
|
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
void integer_tests(T* = 0)
|
void integer_tests(T* = 0)
|
||||||
{
|
{
|
||||||
const int number_of_containers = 11;
|
const int number_of_containers = 12;
|
||||||
T containers[number_of_containers];
|
T containers[number_of_containers];
|
||||||
|
|
||||||
for(int i = 0; i < 5; ++i) {
|
for(int i = 0; i < 5; ++i) {
|
||||||
@@ -30,6 +35,11 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
|||||||
containers[9].insert(-1);
|
containers[9].insert(-1);
|
||||||
containers[10].insert(-1);
|
containers[10].insert(-1);
|
||||||
containers[10].insert(1);
|
containers[10].insert(1);
|
||||||
|
containers[11].insert(1);
|
||||||
|
containers[11].insert(2);
|
||||||
|
containers[11].insert(3);
|
||||||
|
containers[11].insert(4);
|
||||||
|
containers[11].insert(5);
|
||||||
|
|
||||||
HASH_NAMESPACE::hash<T> hasher;
|
HASH_NAMESPACE::hash<T> hasher;
|
||||||
|
|
||||||
@@ -61,5 +71,9 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef CONTAINER_TYPE
|
#undef CONTAINER_TYPE
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user