From 63454c11aa909eafabe5b91233017da599b40d01 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Thu, 6 Oct 2016 23:17:20 +0200 Subject: [PATCH] unit-tests for optional ref conversion fix --- test/optional_test_ref_portable_minimum.cpp | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/optional_test_ref_portable_minimum.cpp b/test/optional_test_ref_portable_minimum.cpp index 303559a..c929c3a 100644 --- a/test/optional_test_ref_portable_minimum.cpp +++ b/test/optional_test_ref_portable_minimum.cpp @@ -430,6 +430,23 @@ void test_swap() BOOST_TEST(boost::addressof(*o2_) == boost::addressof(v1)); } +template +void test_convertability_of_compatible_reference_types() +{ + typename concrete_type_of::type v1(1); + optional oN, o1(v1); + optional uN(oN), u1(o1); + BOOST_TEST(!uN); + BOOST_TEST(u1); + BOOST_TEST(boost::addressof(*u1) == boost::addressof(*o1)); + + uN = o1; + u1 = oN; + BOOST_TEST(!u1); + BOOST_TEST(uN); + BOOST_TEST(boost::addressof(*uN) == boost::addressof(*o1)); +} + template void test_optional_ref() { @@ -472,5 +489,11 @@ int main() test_optional_const_ref(); test_optional_const_ref< optional >(); + test_convertability_of_compatible_reference_types(); + test_convertability_of_compatible_reference_types(); + test_convertability_of_compatible_reference_types(); + test_convertability_of_compatible_reference_types(); + test_convertability_of_compatible_reference_types, const optional >(); + return boost::report_errors(); }