From 06fe6a9cbac06e197997d72bd373d59ec3e29fb8 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 5 Nov 2012 18:33:54 +0000 Subject: [PATCH] Hash: Extra test to check different platform's floating point functions. [SVN r81210] --- hash/test/extra/Jamfile.v2 | 13 ++++++ hash/test/extra/check_float_funcs.cpp | 58 +++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 hash/test/extra/Jamfile.v2 create mode 100644 hash/test/extra/check_float_funcs.cpp diff --git a/hash/test/extra/Jamfile.v2 b/hash/test/extra/Jamfile.v2 new file mode 100644 index 0000000..243c1b1 --- /dev/null +++ b/hash/test/extra/Jamfile.v2 @@ -0,0 +1,13 @@ + +# Copyright 2012 Daniel James. +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +import testing ; + +build-project .. ; + +test-suite functional/hash/config + : + [ compile check_float_funcs.cpp ] + ; \ No newline at end of file diff --git a/hash/test/extra/check_float_funcs.cpp b/hash/test/extra/check_float_funcs.cpp new file mode 100644 index 0000000..a937082 --- /dev/null +++ b/hash/test/extra/check_float_funcs.cpp @@ -0,0 +1,58 @@ + +// Copyright 2012 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +namespace test +{ + template + struct check_return_type + { + template + static void equals(T2) + { + BOOST_STATIC_ASSERT((boost::is_same::value)); + } + + template + static void equals_ref(T2&) + { + BOOST_STATIC_ASSERT((boost::is_same::value)); + } + + template + static void convertible(T2) + { + BOOST_STATIC_ASSERT((boost::is_convertible::value)); + } + }; +} + +int main() { + float f = 0; + double d = 0; + long double l = 0; + + test::check_return_type::equals(std::ldexp(f, 0)); + test::check_return_type::equals(std::ldexp(d, 0)); + test::check_return_type::equals(std::ldexp(l, 0)); + + int dummy = 0; + + test::check_return_type::equals(std::frexp(f, &dummy)); + test::check_return_type::equals(std::frexp(d, &dummy)); + test::check_return_type::equals(std::frexp(l, &dummy)); + +#if BOOST_HASH_USE_FPCLASSIFY + + int (*fpc1)(float) = std::fpclassify; + int (*fpc2)(double) = std::fpclassify; + int (*fpc3)(long double) = std::fpclassify; + +#endif +} \ No newline at end of file