// Copyright 2018 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 "./config.hpp" #ifndef BOOST_HASH_TEST_STD_INCLUDES # include #endif #include #include #if BOOST_HASH_HAS_OPTIONAL #include #include void test_optional_int() { std::optional x1a; std::optional x1b; std::optional x2a(10); std::optional x2b(x2a); std::optional x3(20); boost::hash > hasher; BOOST_TEST(hasher(x1a) == hasher(x1a)); BOOST_TEST(hasher(x1a) == hasher(x1b)); BOOST_TEST(hasher(x1a) != hasher(x2a)); BOOST_TEST(hasher(x1a) != hasher(x3)); BOOST_TEST(hasher(x2a) == hasher(x2a)); BOOST_TEST(hasher(x2b) == hasher(x2b)); BOOST_TEST(hasher(x2a) != hasher(x3)); BOOST_TEST(hasher(x3) == hasher(x3)); } void test_optional_string() { std::optional x1a; std::optional x1b; std::optional x2a("10"); std::optional x2b(x2a); std::optional x3("20"); boost::hash > hasher; BOOST_TEST(hasher(x1a) == hasher(x1a)); BOOST_TEST(hasher(x1a) == hasher(x1b)); BOOST_TEST(hasher(x1a) != hasher(x2a)); BOOST_TEST(hasher(x1a) != hasher(x3)); BOOST_TEST(hasher(x2a) == hasher(x2a)); BOOST_TEST(hasher(x2b) == hasher(x2b)); BOOST_TEST(hasher(x2a) != hasher(x3)); BOOST_TEST(hasher(x3) == hasher(x3)); } #endif int main() { #if BOOST_HASH_HAS_OPTIONAL test_optional_int(); test_optional_string(); #else BOOST_LIGHTWEIGHT_TEST_OSTREAM << " not available." << std::endl; #endif return boost::report_errors(); }