diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index 41ac3ae..ebff22e 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -646,37 +646,93 @@ TEST(span_test, from_container_constructor) } } -TEST(span_test, from_convertible_span_constructor){{span avd; -span avcd = avd; -static_cast(avcd); -} - +TEST(span_test, from_convertible_span_constructor) { -#ifdef CONFIRM_COMPILATION_ERRORS - span avd; - span avb = avd; - static_cast(avb); -#endif -} + const auto terminateHandler = std::set_terminate([] { + std::cerr << "Expected Death. from_convertible_span_constructor"; + std::abort(); + }); + const auto expected = GetExpectedDeathString(terminateHandler); + + { + span avd; + span avcd = avd; + static_cast(avcd); + } + + { + std::array arr{}; + span avd{arr}; + span avcd = avd; + static_cast(avcd); + } + + { + std::array arr{}; + span avd{arr}; + span avcd = avd; + static_cast(avcd); + } + + { + std::array arr{}; + span avd{arr}; + span avcd{avd}; + static_cast(avcd); + } + + { + std::array arr{}; + span avd{arr}; + using T = span; + EXPECT_DEATH(T{avd}, expected); + } #ifdef CONFIRM_COMPILATION_ERRORS -{ - span s; - span s2 = s; - static_cast(s2); -} + { + std::array arr{}; + span avd{arr}; + span avcd = avd; + static_cast(avcd); + } -{ - span s; - span s2 = s; - static_cast(s2); -} + { + std::array arr{}; + span avd{arr}; + span avcd = avd; + static_cast(avcd); + } -{ - span s; - span s2 = s; - static_cast(s2); -} + { + std::array arr{}; + span avd{arr}; + span avcd = avd; + static_cast(avcd); + } + + { + span avd; + span avb = avd; + static_cast(avb); + } + + { + span s; + span s2 = s; + static_cast(s2); + } + + { + span s; + span s2 = s; + static_cast(s2); + } + + { + span s; + span s2 = s; + static_cast(s2); + } #endif }