From ddde9e153d150ba5b635825898a2bde45512b635 Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Thu, 19 Mar 2020 14:08:04 -0700 Subject: [PATCH] update convertibility test --- tests/span_compatibility_tests.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/span_compatibility_tests.cpp b/tests/span_compatibility_tests.cpp index 4be3c4d..e344e88 100644 --- a/tests/span_compatibility_tests.cpp +++ b/tests/span_compatibility_tests.cpp @@ -42,14 +42,11 @@ static_assert(std::is_convertible::value, "std::is_convertible< static_assert(!std::is_convertible::value, "!std::is_convertible"); -TEST(span_compatibility_tests, assertion_tests) +template +void ArrayConvertibilityCheck() { - int arr[3]{10, 20, 30}; - std::array stl{{100, 200, 300}}; - #if __cplusplus >= 201703l - // This std::is_convertible_v fails for C++14 - // so these conversions aren't valid in C++14 + if constexpr (std::is_convertible::value) { std::array stl_nullptr{{nullptr, nullptr, nullptr}}; gsl::span sp_const_nullptr_1{stl_nullptr}; @@ -60,11 +57,22 @@ TEST(span_compatibility_tests, assertion_tests) EXPECT_TRUE(sp_const_nullptr_2.data() == stl_nullptr.data()); EXPECT_TRUE(sp_const_nullptr_2.size() == 3); - static_assert(std::is_same < decltype(span{stl_nullptr}), span); - static_assert(std::is_same < decltype(span{std::as_const(stl_nullptr)}), - span); + static_assert(std::is_same>::value, + "std::is_same< decltype(span{stl_nullptr}), span>::value"); + static_assert( + std::is_same>::value, + "std::is_same< decltype(span{std::as_const(stl_nullptr)}), span>::value"); } #endif +} + +TEST(span_compatibility_tests, assertion_tests) +{ + int arr[3]{10, 20, 30}; + std::array stl{{100, 200, 300}}; + + ArrayConvertibilityCheck(); { gsl::span sp_dyn;