From b6b1e9c3cf1200ad5d912d4bd63364286863cbfc Mon Sep 17 00:00:00 2001 From: jordan maples Date: Fri, 14 Feb 2020 16:13:21 -0800 Subject: [PATCH 1/2] assert -> expect_true --- tests/span_compatibility_tests.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/span_compatibility_tests.cpp b/tests/span_compatibility_tests.cpp index 62793e7..d4cde0c 100644 --- a/tests/span_compatibility_tests.cpp +++ b/tests/span_compatibility_tests.cpp @@ -48,22 +48,22 @@ template static constexpr bool AsWritableBytesCompilesFor()))>> = true; -TEST(span_test, std_span_compatibilty_assertion_tests) +TEST(span_compatibility_tests, assertion_tests) { int arr[3]{10, 20, 30}; std::array stl{{100, 200, 300}}; { gsl::span sp_dyn; - assert(sp_dyn.data() == nullptr); - assert(sp_dyn.size() == 0); - assert(sp_dyn.empty()); + EXPECT_TRUE(sp_dyn.data() == nullptr); + EXPECT_TRUE(sp_dyn.size() == 0); + EXPECT_TRUE(sp_dyn.empty()); } { gsl::span sp_zero; - assert(sp_zero.data() == nullptr); - assert(sp_zero.size() == 0); - assert(sp_zero.empty()); + EXPECT_TRUE(sp_zero.data() == nullptr); + EXPECT_TRUE(sp_zero.size() == 0); + EXPECT_TRUE(sp_zero.empty()); gsl::span sp_dyn_a(arr, 3); gsl::span sp_dyn_b(begin(arr), 3); From 6b01a0488b1157a2c49805b85becd09e1fe84f57 Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Fri, 14 Feb 2020 16:25:25 -0800 Subject: [PATCH 2/2] Update span_compatibility_tests.cpp some fixes. --- tests/span_compatibility_tests.cpp | 35 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/span_compatibility_tests.cpp b/tests/span_compatibility_tests.cpp index d4cde0c..57a85e7 100644 --- a/tests/span_compatibility_tests.cpp +++ b/tests/span_compatibility_tests.cpp @@ -41,13 +41,6 @@ static_assert(std::is_convertible::value, "std::is_convertible< static_assert(!std::is_convertible::value, "!std::is_convertible"); -template -static constexpr bool AsWritableBytesCompilesFor = false; - -template -static constexpr bool AsWritableBytesCompilesFor()))>> = - true; - TEST(span_compatibility_tests, assertion_tests) { int arr[3]{10, 20, 30}; @@ -501,15 +494,6 @@ TEST(span_compatibility_tests, assertion_tests) static_assert(noexcept(as_writable_bytes(sp_dyn)), "noexcept(as_writable_bytes(sp_dyn))"); static_assert(noexcept(as_writable_bytes(sp_nine)), "noexcept(as_writable_bytes(sp_nine))"); - static_assert(AsWritableBytesCompilesFor>, - "AsWritableBytesCompilesFor>"); - static_assert(AsWritableBytesCompilesFor>, - "AsWritableBytesCompilesFor>"); - static_assert(!AsWritableBytesCompilesFor>, - "!AsWritableBytesCompilesFor>"); - static_assert(!AsWritableBytesCompilesFor>, - "!AsWritableBytesCompilesFor>"); - auto sp_1 = as_bytes(sp_dyn); auto sp_2 = as_bytes(sp_nine); auto sp_3 = as_bytes(sp_const_dyn); @@ -1064,3 +1048,22 @@ static_assert(std::is_convertible&, gsl::span>::va static_assert(std::is_convertible&, gsl::span>::value, "std::is_convertible&, gsl::span>"); + + +#if __cplusplus >= 201703l +template +inline constexpr bool AsWritableBytesCompilesFor = false; + +template +inline constexpr bool AsWritableBytesCompilesFor()))>> = + true; + +static_assert(AsWritableBytesCompilesFor>, + "AsWritableBytesCompilesFor>"); +static_assert(AsWritableBytesCompilesFor>, + "AsWritableBytesCompilesFor>"); +static_assert(!AsWritableBytesCompilesFor>, + "!AsWritableBytesCompilesFor>"); +static_assert(!AsWritableBytesCompilesFor>, + "!AsWritableBytesCompilesFor>"); +#endif // __cplusplus >= 201703l