diff options
author | Anas Nashif <anas.nashif@intel.com> | 2013-08-26 08:15:55 -0400 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-08-26 08:15:55 -0400 |
commit | bb4dd8289b351fae6b55e303f189127a394a1edd (patch) | |
tree | 77c9c35a31b1459dd7988c2448e797d142530c41 /libs/variant | |
parent | 1a78a62555be32868418fe52f8e330c9d0f95d5a (diff) | |
download | boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.gz boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.bz2 boost-bb4dd8289b351fae6b55e303f189127a394a1edd.zip |
Imported Upstream version 1.51.0upstream/1.51.0
Diffstat (limited to 'libs/variant')
-rw-r--r-- | libs/variant/test/Jamfile.v2 | 1 | ||||
-rw-r--r-- | libs/variant/test/hash_variant_test.cpp | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/libs/variant/test/Jamfile.v2 b/libs/variant/test/Jamfile.v2 index 2e3e855292..456f108336 100644 --- a/libs/variant/test/Jamfile.v2 +++ b/libs/variant/test/Jamfile.v2 @@ -32,6 +32,7 @@ test-suite variant [ run variant_reference_test.cpp ] [ run variant_comparison_test.cpp ] [ run variant_visit_test.cpp ] + [ run hash_variant_test.cpp ] ; diff --git a/libs/variant/test/hash_variant_test.cpp b/libs/variant/test/hash_variant_test.cpp new file mode 100644 index 0000000000..0678832438 --- /dev/null +++ b/libs/variant/test/hash_variant_test.cpp @@ -0,0 +1,34 @@ +// Copyright (c) 2011 +// Antony Polukhin +// +// 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 "boost/test/minimal.hpp" +#include "boost/variant/detail/hash_variant.hpp" +#include "boost/variant.hpp" +#include "boost/functional/hash/hash.hpp" + +void run() +{ + typedef boost::variant<bool, int, unsigned int, double> variant_type; + boost::hash<variant_type> hasher; + + variant_type bool_variant1 = true; + variant_type bool_variant2 = false; + variant_type int_variant = 1; + variant_type float_variant = 1.0; + variant_type uint_variant = static_cast<unsigned int>(1); + + BOOST_CHECK(hasher(bool_variant1) != hasher(bool_variant2)); + BOOST_CHECK(hasher(bool_variant1) == hasher(bool_variant1)); + BOOST_CHECK(hasher(int_variant) != hasher(uint_variant)); + BOOST_CHECK(hasher(float_variant) != hasher(uint_variant)); +} + +int test_main(int , char* []) +{ + run(); + return 0; +} |