From 5099e8fa3ea6d43fb0a20a47644437c6838af1aa Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Thu, 12 Dec 2019 11:15:41 -0800 Subject: [PATCH] removed string_view for string in tests --- tests/algorithm_tests.cpp | 9 ++-- tests/assertion_tests.cpp | 9 ++-- tests/at_tests.cpp | 34 ++++++------ tests/multi_span_tests.cpp | 88 +++++++++++++++--------------- tests/notnull_tests.cpp | 32 +++++------ tests/span_tests.cpp | 62 ++++++++++----------- tests/strict_notnull_tests.cpp | 12 ++--- tests/strided_span_tests.cpp | 98 +++++++++++++++++----------------- tests/string_span_tests.cpp | 12 ++--- tests/utils_tests.cpp | 12 ++--- 10 files changed, 183 insertions(+), 185 deletions(-) diff --git a/tests/algorithm_tests.cpp b/tests/algorithm_tests.cpp index 299bb96..0866654 100644 --- a/tests/algorithm_tests.cpp +++ b/tests/algorithm_tests.cpp @@ -35,11 +35,10 @@ #include // for copy #include // for span #include // for array -#include #include // for size_t namespace{ -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); } namespace gsl @@ -234,9 +233,9 @@ TEST(algorithm_tests, small_destination_span) const span dst_span_dyn(dst); const span dst_span_static(dst); - EXPECT_DEATH(copy(src_span_dyn, dst_span_dyn), deathstring.data()); - EXPECT_DEATH(copy(src_span_dyn, dst_span_static), deathstring.data()); - EXPECT_DEATH(copy(src_span_static, dst_span_dyn), deathstring.data()); + EXPECT_DEATH(copy(src_span_dyn, dst_span_dyn), deathstring); + EXPECT_DEATH(copy(src_span_dyn, dst_span_static), deathstring); + EXPECT_DEATH(copy(src_span_static, dst_span_dyn), deathstring); #ifdef CONFIRM_COMPILATION_ERRORS copy(src_span_static, dst_span_static); diff --git a/tests/assertion_tests.cpp b/tests/assertion_tests.cpp index e873f75..7009f86 100644 --- a/tests/assertion_tests.cpp +++ b/tests/assertion_tests.cpp @@ -34,7 +34,6 @@ #include #include // for fail_fast (ptr only), Ensures, Expects -#include using namespace gsl; namespace @@ -52,7 +51,7 @@ int g(int i) return i; } -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); } // namespace TEST(assertion_tests, expects) @@ -61,9 +60,9 @@ TEST(assertion_tests, expects) std::cerr << "Expected Death. expects"; std::abort(); }); - + EXPECT_TRUE(f(2) == 2); - EXPECT_DEATH(f(10), deathstring.data()); + EXPECT_DEATH(f(10), deathstring); } @@ -75,7 +74,7 @@ TEST(assertion_tests, ensures) }); EXPECT_TRUE(g(2) == 3); - EXPECT_DEATH(g(9), deathstring.data()); + EXPECT_DEATH(g(9), deathstring); } #if __clang__ || __GNUC__ diff --git a/tests/at_tests.cpp b/tests/at_tests.cpp index 0d2196a..29359e9 100644 --- a/tests/at_tests.cpp +++ b/tests/at_tests.cpp @@ -41,7 +41,7 @@ #include // for vector namespace{ -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); } TEST(at_tests, static_array) @@ -59,10 +59,10 @@ TEST(at_tests, static_array) std::abort(); }); - EXPECT_DEATH(gsl::at(a, -1), deathstring.data()); - EXPECT_DEATH(gsl::at(a, 4), deathstring.data()); - EXPECT_DEATH(gsl::at(c_a, -1), deathstring.data()); - EXPECT_DEATH(gsl::at(c_a, 4), deathstring.data()); + EXPECT_DEATH(gsl::at(a, -1), deathstring); + EXPECT_DEATH(gsl::at(a, 4), deathstring); + EXPECT_DEATH(gsl::at(c_a, -1), deathstring); + EXPECT_DEATH(gsl::at(c_a, 4), deathstring); } TEST(at_tests, std_array) @@ -80,10 +80,10 @@ TEST(at_tests, std_array) std::abort(); }); - EXPECT_DEATH(gsl::at(a, -1), deathstring.data()); - EXPECT_DEATH(gsl::at(a, 4), deathstring.data()); - EXPECT_DEATH(gsl::at(c_a, -1), deathstring.data()); - EXPECT_DEATH(gsl::at(c_a, 4), deathstring.data()); + EXPECT_DEATH(gsl::at(a, -1), deathstring); + EXPECT_DEATH(gsl::at(a, 4), deathstring); + EXPECT_DEATH(gsl::at(c_a, -1), deathstring); + EXPECT_DEATH(gsl::at(c_a, 4), deathstring); } TEST(at_tests, std_vector) @@ -101,10 +101,10 @@ TEST(at_tests, std_vector) std::abort(); }); - EXPECT_DEATH(gsl::at(a, -1), deathstring.data()); - EXPECT_DEATH(gsl::at(a, 4), deathstring.data()); - EXPECT_DEATH(gsl::at(c_a, -1), deathstring.data()); - EXPECT_DEATH(gsl::at(c_a, 4), deathstring.data()); + EXPECT_DEATH(gsl::at(a, -1), deathstring); + EXPECT_DEATH(gsl::at(a, 4), deathstring); + EXPECT_DEATH(gsl::at(c_a, -1), deathstring); + EXPECT_DEATH(gsl::at(c_a, 4), deathstring); } TEST(at_tests, InitializerList) @@ -121,10 +121,10 @@ TEST(at_tests, InitializerList) std::abort(); }); - EXPECT_DEATH(gsl::at(a, -1), deathstring.data()); - EXPECT_DEATH(gsl::at(a, 4), deathstring.data()); - EXPECT_DEATH(gsl::at({1, 2, 3, 4}, -1), deathstring.data()); - EXPECT_DEATH(gsl::at({1, 2, 3, 4}, 4), deathstring.data()); + EXPECT_DEATH(gsl::at(a, -1), deathstring); + EXPECT_DEATH(gsl::at(a, 4), deathstring); + EXPECT_DEATH(gsl::at({1, 2, 3, 4}, -1), deathstring); + EXPECT_DEATH(gsl::at({1, 2, 3, 4}, 4), deathstring); } #if !defined(_MSC_VER) || defined(__clang__) || _MSC_VER >= 1910 diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index 24bcf61..490ce83 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -139,7 +139,7 @@ void fn(const Bounds&) static_assert(Bounds::static_size == 60, "static bounds is wrong size"); } -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); } // namespace TEST(multi_span_test, default_constructor) @@ -262,18 +262,18 @@ TEST(multi_span_test, from_nullptr_length_constructor) { { auto workaround_macro = []() { const multi_span s{nullptr, 1}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); auto const_workaround_macro = []() { const multi_span cs{nullptr, 1}; }; - EXPECT_DEATH(const_workaround_macro(), deathstring.data()); + EXPECT_DEATH(const_workaround_macro(), deathstring); } { auto workaround_macro = []() { const multi_span s{nullptr, 1}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); auto const_workaround_macro = []() { const multi_span s{nullptr, 1}; }; - EXPECT_DEATH(const_workaround_macro(), deathstring.data()); + EXPECT_DEATH(const_workaround_macro(), deathstring); } { @@ -385,7 +385,7 @@ TEST(multi_span_test, from_pointer_length_constructor) { int* p = nullptr; auto workaround_macro = [=]() { const multi_span s{p, 2}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } } @@ -429,25 +429,25 @@ TEST(multi_span_test, from_pointer_pointer_constructor) { auto workaround_macro = [&]() { const multi_span s{&arr[1], &arr[0]}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { int* p = nullptr; auto workaround_macro = [&]() { const multi_span s{&arr[0], p}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { int* p = nullptr; auto workaround_macro = [&]() { const multi_span s{p, p}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { int* p = nullptr; auto workaround_macro = [&]() { const multi_span s{&arr[0], p}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } } @@ -605,7 +605,7 @@ TEST(multi_span_test, from_dynamic_array_constructor) multi_span s(arr, 10); EXPECT_TRUE(s.length() == 120); EXPECT_TRUE(s.data() == &arr[0][0][0]); - EXPECT_DEATH(s[10][3][4], deathstring.data()); + EXPECT_DEATH(s[10][3][4], deathstring); } { @@ -838,7 +838,7 @@ TEST(multi_span_test, from_convertible_span_constructor) }); auto f = [&]() { multi_span av1(nullptr); }; - EXPECT_DEATH(f(), deathstring.data()); + EXPECT_DEATH(f(), deathstring); #endif #ifdef CONFIRM_COMPILATION_ERRORS @@ -944,7 +944,7 @@ TEST(multi_span_test, first) std::abort(); }); - EXPECT_DEATH(av.first(6).length(), deathstring.data()); + EXPECT_DEATH(av.first(6).length(), deathstring); } { @@ -992,7 +992,7 @@ TEST(multi_span_test, last) std::abort(); }); - EXPECT_DEATH(av.last(6).length(), deathstring.data()); + EXPECT_DEATH(av.last(6).length(), deathstring); } { @@ -1032,8 +1032,8 @@ TEST(multi_span_test, subspan) EXPECT_TRUE((av.subspan<0, 5>().bounds()) == static_bounds<5>()); EXPECT_TRUE((av.subspan<0, 5>().length()) == 5); EXPECT_TRUE(av.subspan(0, 5).length() == 5); - EXPECT_DEATH(av.subspan(0, 6).length(), deathstring.data()); - EXPECT_DEATH(av.subspan(1, 5).length(), deathstring.data()); + EXPECT_DEATH(av.subspan(0, 6).length(), deathstring); + EXPECT_DEATH(av.subspan(1, 5).length(), deathstring); } { @@ -1041,7 +1041,7 @@ TEST(multi_span_test, subspan) EXPECT_TRUE((av.subspan<5, 0>().bounds()) == static_bounds<0>()); EXPECT_TRUE((av.subspan<5, 0>().length()) == 0); EXPECT_TRUE(av.subspan(5, 0).length() == 0); - EXPECT_DEATH(av.subspan(6, 0).length(), deathstring.data()); + EXPECT_DEATH(av.subspan(6, 0).length(), deathstring); } { @@ -1049,13 +1049,13 @@ TEST(multi_span_test, subspan) EXPECT_TRUE((av.subspan<0, 0>().bounds()) == static_bounds<0>()); EXPECT_TRUE((av.subspan<0, 0>().length()) == 0); EXPECT_TRUE(av.subspan(0, 0).length() == 0); - EXPECT_DEATH((av.subspan<1, 0>().length()), deathstring.data()); + EXPECT_DEATH((av.subspan<1, 0>().length()), deathstring); } { multi_span av; EXPECT_TRUE(av.subspan(0).length() == 0); - EXPECT_DEATH(av.subspan(1).length(), deathstring.data()); + EXPECT_DEATH(av.subspan(1).length(), deathstring); } { @@ -1064,7 +1064,7 @@ TEST(multi_span_test, subspan) EXPECT_TRUE(av.subspan(1).length() == 4); EXPECT_TRUE(av.subspan(4).length() == 1); EXPECT_TRUE(av.subspan(5).length() == 0); - EXPECT_DEATH(av.subspan(6).length(), deathstring.data()); + EXPECT_DEATH(av.subspan(6).length(), deathstring); auto av2 = av.subspan(1); for (int i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); } @@ -1075,7 +1075,7 @@ TEST(multi_span_test, subspan) EXPECT_TRUE(av.subspan(1).length() == 4); EXPECT_TRUE(av.subspan(4).length() == 1); EXPECT_TRUE(av.subspan(5).length() == 0); - EXPECT_DEATH(av.subspan(6).length(), deathstring.data()); + EXPECT_DEATH(av.subspan(6).length(), deathstring); auto av2 = av.subspan(1); for (int i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); } @@ -1113,7 +1113,7 @@ TEST(multi_span_test, extent) multi_span s; EXPECT_TRUE(s.extent() == 0); EXPECT_TRUE(s.extent(0) == 0); - EXPECT_DEATH(s.extent(1), deathstring.data()); + EXPECT_DEATH(s.extent(1), deathstring); #ifdef CONFIRM_COMPILATION_ERRORS EXPECT_TRUE(s.extent<1>() == 0); #endif @@ -1123,7 +1123,7 @@ TEST(multi_span_test, extent) multi_span s; EXPECT_TRUE(s.extent() == 0); EXPECT_TRUE(s.extent(0) == 0); - EXPECT_DEATH(s.extent(1), deathstring.data()); + EXPECT_DEATH(s.extent(1), deathstring); } { @@ -1135,7 +1135,7 @@ TEST(multi_span_test, extent) EXPECT_TRUE(s.extent<1>() == 2); EXPECT_TRUE(s.extent(0) == 1); EXPECT_TRUE(s.extent(1) == 2); - EXPECT_DEATH(s.extent(3), deathstring.data()); + EXPECT_DEATH(s.extent(3), deathstring); } { @@ -1147,7 +1147,7 @@ TEST(multi_span_test, extent) EXPECT_TRUE(s.extent<1>() == 2); EXPECT_TRUE(s.extent(0) == 0); EXPECT_TRUE(s.extent(1) == 2); - EXPECT_DEATH(s.extent(3), deathstring.data()); + EXPECT_DEATH(s.extent(3), deathstring); } } @@ -1163,7 +1163,7 @@ TEST(multi_span_test, operator_function_call) { multi_span s = arr; EXPECT_TRUE(s(0) == 1); - EXPECT_DEATH(s(5), deathstring.data()); + EXPECT_DEATH(s(5), deathstring); } int arr2d[2][3] = {1, 2, 3, 4, 5, 6}; @@ -1322,17 +1322,17 @@ TEST(multi_span_test, bounds_checks) }); // out of bounds - EXPECT_DEATH(av[1][3] = 3, deathstring.data()); - EXPECT_DEATH((av[{1, 3}] = 3), deathstring.data()); + EXPECT_DEATH(av[1][3] = 3, deathstring); + EXPECT_DEATH((av[{1, 3}] = 3), deathstring); - EXPECT_DEATH(av[10][2], deathstring.data()); - EXPECT_DEATH((av[{10, 2}]), deathstring.data()); + EXPECT_DEATH(av[10][2], deathstring); + EXPECT_DEATH((av[{10, 2}]), deathstring); - EXPECT_DEATH(av[-1][0], deathstring.data()); - EXPECT_DEATH((av[{-1, 0}]), deathstring.data()); + EXPECT_DEATH(av[-1][0], deathstring); + EXPECT_DEATH((av[{-1, 0}]), deathstring); - EXPECT_DEATH(av[0][-1], deathstring.data()); - EXPECT_DEATH((av[{0, -1}]), deathstring.data()); + EXPECT_DEATH(av[0][-1], deathstring); + EXPECT_DEATH((av[{0, -1}]), deathstring); } TEST(multi_span_test, span_parameter_test) @@ -1459,9 +1459,9 @@ TEST(multi_span_test, empty_spans) multi_span empty_av(nullptr); EXPECT_TRUE(empty_av.bounds().index_bounds() == multi_span_index<1>{0}); - EXPECT_DEATH(empty_av[0], deathstring.data()); - EXPECT_DEATH(empty_av.begin()[0], deathstring.data()); - EXPECT_DEATH(empty_av.cbegin()[0], deathstring.data()); + EXPECT_DEATH(empty_av[0], deathstring); + EXPECT_DEATH(empty_av.begin()[0], deathstring); + EXPECT_DEATH(empty_av.cbegin()[0], deathstring); for (auto& v : empty_av) { (void) v; @@ -1472,9 +1472,9 @@ TEST(multi_span_test, empty_spans) { multi_span empty_av = {}; EXPECT_TRUE(empty_av.bounds().index_bounds() == multi_span_index<1>{0}); - EXPECT_DEATH(empty_av[0], deathstring.data()); - EXPECT_DEATH(empty_av.begin()[0], deathstring.data()); - EXPECT_DEATH(empty_av.cbegin()[0], deathstring.data()); + EXPECT_DEATH(empty_av[0], deathstring); + EXPECT_DEATH(empty_av.begin()[0], deathstring); + EXPECT_DEATH(empty_av.cbegin()[0], deathstring); for (auto& v : empty_av) { (void) v; @@ -1709,7 +1709,7 @@ TEST(multi_span_test, span_structure_size) std::abort(); }); - EXPECT_DEATH(av1[10][3][4], deathstring.data()); + EXPECT_DEATH(av1[10][3][4], deathstring); multi_span av2 = as_multi_span(av1, dim(5), dim<6>(), dim<4>()); @@ -1802,13 +1802,13 @@ TEST(multi_span_test, fixed_size_conversions) std::cerr << "Expected Death. fixed_size_conversions"; std::abort(); }); - + { auto f = [&]() { const multi_span av9 = {arr2, 2}; (void) av9; }; - EXPECT_DEATH(f(), deathstring.data()); + EXPECT_DEATH(f(), deathstring); } // this should fail - we are trying to assign a small dynamic a_v to a fixed_size larger one @@ -1817,7 +1817,7 @@ TEST(multi_span_test, fixed_size_conversions) const multi_span av2 = av; (void) av2; }; - EXPECT_DEATH(f(), deathstring.data()); + EXPECT_DEATH(f(), deathstring); } TEST(multi_span_test, as_writeable_bytes) diff --git a/tests/notnull_tests.cpp b/tests/notnull_tests.cpp index 4ad7f8d..1649ed6 100644 --- a/tests/notnull_tests.cpp +++ b/tests/notnull_tests.cpp @@ -53,7 +53,7 @@ struct fail_fast; using namespace gsl; namespace{ -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); } struct MyBase @@ -182,7 +182,7 @@ TEST(notnull_tests, TestNotNullConstructors) std::make_shared(10)); // shared_ptr is nullptr assignable int* pi = nullptr; - EXPECT_DEATH((not_null(pi)), deathstring.data()); + EXPECT_DEATH((not_null(pi)), deathstring); } { @@ -239,8 +239,8 @@ TEST(notnull_tests, TestNotNullConstructors) { // from returned pointer - EXPECT_DEATH(helper(return_pointer()), deathstring.data()); - EXPECT_DEATH(helper_const(return_pointer()), deathstring.data()); + EXPECT_DEATH(helper(return_pointer()), deathstring); + EXPECT_DEATH(helper_const(return_pointer()), deathstring); } } @@ -310,7 +310,7 @@ TEST(notnull_tests, TestNotNullAssignment) EXPECT_TRUE(helper(p)); int* q = nullptr; - EXPECT_DEATH(p = not_null(q), deathstring.data()); + EXPECT_DEATH(p = not_null(q), deathstring); } TEST(notnull_tests, TestNotNullRawPointerComparison) @@ -469,7 +469,7 @@ TEST(notnull_tests, TestNotNullConstructorTypeDeduction) int* p1 = nullptr; const not_null x{p1}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { @@ -477,14 +477,14 @@ TEST(notnull_tests, TestNotNullConstructorTypeDeduction) const int* p1 = nullptr; const not_null x{p1}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { int* p = nullptr; - EXPECT_DEATH(helper(not_null{p}), deathstring.data()); - EXPECT_DEATH(helper_const(not_null{p}), deathstring.data()); + EXPECT_DEATH(helper(not_null{p}), deathstring); + EXPECT_DEATH(helper_const(not_null{p}), deathstring); } #ifdef CONFIRM_COMPILATION_ERRORS @@ -531,7 +531,7 @@ TEST(notnull_tests, TestMakeNotNull) const auto x = make_not_null(p1); EXPECT_TRUE(*x == 42); }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { @@ -540,21 +540,21 @@ TEST(notnull_tests, TestMakeNotNull) const auto x = make_not_null(p1); EXPECT_TRUE(*x == 42); }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { int* p = nullptr; - EXPECT_DEATH(helper(make_not_null(p)), deathstring.data()); - EXPECT_DEATH(helper_const(make_not_null(p)), deathstring.data()); + EXPECT_DEATH(helper(make_not_null(p)), deathstring); + EXPECT_DEATH(helper_const(make_not_null(p)), deathstring); } #ifdef CONFIRM_COMPILATION_ERRORS { - EXPECT_DEATH(make_not_null(nullptr), deathstring.data()); - EXPECT_DEATH(helper(make_not_null(nullptr)), deathstring.data()); - EXPECT_DEATH(helper_const(make_not_null(nullptr)), deathstring.data()); + EXPECT_DEATH(make_not_null(nullptr), deathstring); + EXPECT_DEATH(helper(make_not_null(nullptr)), deathstring); + EXPECT_DEATH(helper_const(make_not_null(nullptr)), deathstring); } #endif } diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index 7746c0a..c60383a 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -75,7 +75,7 @@ struct AddressOverloaded return {}; } }; -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); } // namespace TEST(span_test, constructors) @@ -139,21 +139,21 @@ TEST(span_test, from_nullptr_size_constructor) auto workaround_macro = []() { const span s{nullptr, narrow_cast::index_type>(0)}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { auto workaround_macro = []() { const span s{nullptr, 1}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); auto const_workaround_macro = []() { const span s{nullptr, 1}; }; - EXPECT_DEATH(const_workaround_macro(), deathstring.data()); + EXPECT_DEATH(const_workaround_macro(), deathstring); } { auto workaround_macro = []() { const span s{nullptr, 1}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); auto const_workaround_macro = []() { const span s{nullptr, 1}; }; - EXPECT_DEATH(const_workaround_macro(), deathstring.data()); + EXPECT_DEATH(const_workaround_macro(), deathstring); } { span s{nullptr, narrow_cast::index_type>(0)}; @@ -223,7 +223,7 @@ TEST(span_test, from_pointer_length_constructor) { int* p = nullptr; auto workaround_macro = [=]() { const span s{p, 2}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { @@ -244,7 +244,7 @@ TEST(span_test, from_pointer_length_constructor) { int* p = nullptr; auto workaround_macro = [=]() { make_span(p, 2); }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } } @@ -282,14 +282,14 @@ TEST(span_test, from_pointer_pointer_construction) // this will fail the std::distance() precondition, which asserts on MSVC debug builds //{ // auto workaround_macro = [&]() { span s{&arr[1], &arr[0]}; }; - // EXPECT_DEATH(workaround_macro(), deathstring.data()); + // EXPECT_DEATH(workaround_macro(), deathstring); //} // this will fail the std::distance() precondition, which asserts on MSVC debug builds //{ // int* p = nullptr; // auto workaround_macro = [&]() { span s{&arr[0], p}; }; - // EXPECT_DEATH(workaround_macro(), deathstring.data()); + // EXPECT_DEATH(workaround_macro(), deathstring); //} { @@ -310,7 +310,7 @@ TEST(span_test, from_pointer_pointer_construction) //{ // int* p = nullptr; // auto workaround_macro = [&]() { span s{&arr[0], p}; }; - // EXPECT_DEATH(workaround_macro(), deathstring.data()); + // EXPECT_DEATH(workaround_macro(), deathstring); //} { @@ -862,7 +862,7 @@ TEST(span_test, from_array_constructor) EXPECT_TRUE(av.first<6>().size() == 6); EXPECT_TRUE(av.first<-1>().size() == -1); #endif - EXPECT_DEATH(av.first(6).size(), deathstring.data()); + EXPECT_DEATH(av.first(6).size(), deathstring); } { @@ -903,7 +903,7 @@ TEST(span_test, from_array_constructor) #ifdef CONFIRM_COMPILATION_ERRORS EXPECT_TRUE(av.last<6>().size() == 6); #endif - EXPECT_DEATH(av.last(6).size(), deathstring.data()); + EXPECT_DEATH(av.last(6).size(), deathstring); } { @@ -942,8 +942,8 @@ TEST(span_test, from_array_constructor) EXPECT_TRUE(decltype(av.subspan<0, 5>())::extent == 5); EXPECT_TRUE(av.subspan(0, 5).size() == 5); - EXPECT_DEATH(av.subspan(0, 6).size(), deathstring.data()); - EXPECT_DEATH(av.subspan(1, 5).size(), deathstring.data()); + EXPECT_DEATH(av.subspan(0, 6).size(), deathstring); + EXPECT_DEATH(av.subspan(1, 5).size(), deathstring); } { @@ -952,7 +952,7 @@ TEST(span_test, from_array_constructor) EXPECT_TRUE(decltype(av.subspan<4, 0>())::extent == 0); EXPECT_TRUE(av.subspan(4, 0).size() == 0); EXPECT_TRUE(av.subspan(5, 0).size() == 0); - EXPECT_DEATH(av.subspan(6, 0).size(), deathstring.data()); + EXPECT_DEATH(av.subspan(6, 0).size(), deathstring); } { @@ -966,13 +966,13 @@ TEST(span_test, from_array_constructor) EXPECT_TRUE((av.subspan<0, 0>().size()) == 0); EXPECT_TRUE(decltype(av.subspan<0, 0>())::extent == 0); EXPECT_TRUE(av.subspan(0, 0).size() == 0); - EXPECT_DEATH((av.subspan<1, 0>().size()), deathstring.data()); + EXPECT_DEATH((av.subspan<1, 0>().size()), deathstring); } { span av; EXPECT_TRUE(av.subspan(0).size() == 0); - EXPECT_DEATH(av.subspan(1).size(), deathstring.data()); + EXPECT_DEATH(av.subspan(1).size(), deathstring); } { @@ -981,7 +981,7 @@ TEST(span_test, from_array_constructor) EXPECT_TRUE(av.subspan(1).size() == 4); EXPECT_TRUE(av.subspan(4).size() == 1); EXPECT_TRUE(av.subspan(5).size() == 0); - EXPECT_DEATH(av.subspan(6).size(), deathstring.data()); + EXPECT_DEATH(av.subspan(6).size(), deathstring); const auto av2 = av.subspan(1); for (int i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); } @@ -992,7 +992,7 @@ TEST(span_test, from_array_constructor) EXPECT_TRUE(av.subspan(1).size() == 4); EXPECT_TRUE(av.subspan(4).size() == 1); EXPECT_TRUE(av.subspan(5).size() == 0); - EXPECT_DEATH(av.subspan(6).size(), deathstring.data()); + EXPECT_DEATH(av.subspan(6).size(), deathstring); const auto av2 = av.subspan(1); for (int i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); } @@ -1009,7 +1009,7 @@ TEST(span_test, from_array_constructor) { span s = arr; EXPECT_TRUE(s.at(0) == 1); - EXPECT_DEATH(s.at(5), deathstring.data()); + EXPECT_DEATH(s.at(5), deathstring); } { @@ -1017,7 +1017,7 @@ TEST(span_test, from_array_constructor) span s = arr2d; EXPECT_TRUE(s.at(0) == 1); EXPECT_TRUE(s.at(1) == 6); - EXPECT_DEATH(s.at(2), deathstring.data()); + EXPECT_DEATH(s.at(2), deathstring); } } @@ -1032,7 +1032,7 @@ TEST(span_test, from_array_constructor) { span s = arr; EXPECT_TRUE(s(0) == 1); - EXPECT_DEATH(s(5), deathstring.data()); + EXPECT_DEATH(s(5), deathstring); } { @@ -1040,7 +1040,7 @@ TEST(span_test, from_array_constructor) span s = arr2d; EXPECT_TRUE(s(0) == 1); EXPECT_TRUE(s(1) == 6); - EXPECT_DEATH(s(2), deathstring.data()); + EXPECT_DEATH(s(2), deathstring); } } @@ -1157,7 +1157,7 @@ TEST(span_test, from_array_constructor) auto beyond = s.end(); EXPECT_TRUE(it != beyond); - EXPECT_DEATH(*beyond, deathstring.data()); + EXPECT_DEATH(*beyond, deathstring); EXPECT_TRUE(beyond - first == 4); EXPECT_TRUE(first - first == 0); @@ -1215,7 +1215,7 @@ TEST(span_test, from_array_constructor) auto beyond = s.cend(); EXPECT_TRUE(it != beyond); - EXPECT_DEATH(*beyond, deathstring.data()); + EXPECT_DEATH(*beyond, deathstring); EXPECT_TRUE(beyond - first == 4); EXPECT_TRUE(first - first == 0); @@ -1259,7 +1259,7 @@ TEST(span_test, from_array_constructor) auto beyond = s.rend(); EXPECT_TRUE(it != beyond); - EXPECT_DEATH(auto _ = *beyond , deathstring.data()); + EXPECT_DEATH(auto _ = *beyond , deathstring); EXPECT_TRUE(beyond - first == 4); EXPECT_TRUE(first - first == 0); @@ -1304,7 +1304,7 @@ TEST(span_test, from_array_constructor) auto beyond = s.crend(); EXPECT_TRUE(it != beyond); - EXPECT_DEATH(auto _ = *beyond, deathstring.data()); + EXPECT_DEATH(auto _ = *beyond, deathstring); EXPECT_TRUE(beyond - first == 4); EXPECT_TRUE(first - first == 0); @@ -1552,7 +1552,7 @@ TEST(span_test, from_array_constructor) const span s2 = s; static_cast(s2); }; - EXPECT_DEATH(f(), deathstring.data()); + EXPECT_DEATH(f(), deathstring); } // but doing so explicitly is ok @@ -1591,7 +1591,7 @@ TEST(span_test, from_array_constructor) const span _s4 = {arr2, 2}; static_cast(_s4); }; - EXPECT_DEATH(f(), deathstring.data()); + EXPECT_DEATH(f(), deathstring); } // this should fail - we are trying to assign a small dynamic span to a fixed_size larger one @@ -1599,7 +1599,7 @@ TEST(span_test, from_array_constructor) const span _s4 = av; static_cast(_s4); }; - EXPECT_DEATH(f(), deathstring.data()); + EXPECT_DEATH(f(), deathstring); } TEST(span_test, interop_with_std_regex) diff --git a/tests/strict_notnull_tests.cpp b/tests/strict_notnull_tests.cpp index faa51c9..60a94fa 100644 --- a/tests/strict_notnull_tests.cpp +++ b/tests/strict_notnull_tests.cpp @@ -43,7 +43,7 @@ struct fail_fast; } // namespace gsl namespace{ -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); } using namespace gsl; @@ -154,7 +154,7 @@ TEST(strict_notnull_tests, TestStrictNotNullConstructorTypeDeduction) std::cerr << "Expected Death. TestStrictNotNullConstructorTypeDeduction"; std::abort(); }); - + { int i = 42; @@ -181,7 +181,7 @@ TEST(strict_notnull_tests, TestStrictNotNullConstructorTypeDeduction) int* p1 = nullptr; const strict_not_null x{p1}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { @@ -189,14 +189,14 @@ TEST(strict_notnull_tests, TestStrictNotNullConstructorTypeDeduction) const int* p1 = nullptr; const strict_not_null x{p1}; }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } { int* p = nullptr; - EXPECT_DEATH(helper(strict_not_null{p}), deathstring.data()); - EXPECT_DEATH(helper_const(strict_not_null{p}), deathstring.data()); + EXPECT_DEATH(helper(strict_not_null{p}), deathstring); + EXPECT_DEATH(helper_const(strict_not_null{p}), deathstring); } #ifdef CONFIRM_COMPILATION_ERRORS diff --git a/tests/strided_span_tests.cpp b/tests/strided_span_tests.cpp index 3016735..a1abd73 100644 --- a/tests/strided_span_tests.cpp +++ b/tests/strided_span_tests.cpp @@ -56,7 +56,7 @@ using namespace gsl; namespace { -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); struct BaseClass { }; @@ -429,15 +429,15 @@ TEST(strided_span_tests, strided_span_bounds) { // incorrect sections - EXPECT_DEATH(av.section(0, 0)[0], deathstring.data()); - EXPECT_DEATH(av.section(1, 0)[0], deathstring.data()); - EXPECT_DEATH(av.section(1, 1)[1], deathstring.data()); + EXPECT_DEATH(av.section(0, 0)[0], deathstring); + EXPECT_DEATH(av.section(1, 0)[0], deathstring); + EXPECT_DEATH(av.section(1, 1)[1], deathstring); - EXPECT_DEATH(av.section(2, 5), deathstring.data()); - EXPECT_DEATH(av.section(5, 2), deathstring.data()); - EXPECT_DEATH(av.section(5, 0), deathstring.data()); - EXPECT_DEATH(av.section(0, 5), deathstring.data()); - EXPECT_DEATH(av.section(5, 5), deathstring.data()); + EXPECT_DEATH(av.section(2, 5), deathstring); + EXPECT_DEATH(av.section(5, 2), deathstring); + EXPECT_DEATH(av.section(5, 0), deathstring); + EXPECT_DEATH(av.section(0, 5), deathstring); + EXPECT_DEATH(av.section(5, 5), deathstring); } { @@ -445,19 +445,19 @@ TEST(strided_span_tests, strided_span_bounds) strided_span sav{av, {{4}, {}}}; EXPECT_TRUE(sav[0] == 0); EXPECT_TRUE(sav[3] == 0); - EXPECT_DEATH(sav[4], deathstring.data()); + EXPECT_DEATH(sav[4], deathstring); } { // zero extent strided_span sav{av, {{}, {1}}}; - EXPECT_DEATH(sav[0], deathstring.data()); + EXPECT_DEATH(sav[0], deathstring); } { // zero extent and stride strided_span sav{av, {{}, {}}}; - EXPECT_DEATH(sav[0], deathstring.data()); + EXPECT_DEATH(sav[0], deathstring); } { @@ -465,7 +465,7 @@ TEST(strided_span_tests, strided_span_bounds) strided_span sav{arr, {4, 1}}; EXPECT_TRUE(sav.bounds().index_bounds() == multi_span_index<1>{4}); EXPECT_TRUE(sav[3] == 3); - EXPECT_DEATH(sav[4], deathstring.data()); + EXPECT_DEATH(sav[4], deathstring); } { @@ -473,7 +473,7 @@ TEST(strided_span_tests, strided_span_bounds) strided_span sav{arr, {2, 1}}; EXPECT_TRUE(sav.bounds().index_bounds() == multi_span_index<1>{2}); EXPECT_TRUE(sav[1] == 1); - EXPECT_DEATH(sav[2], deathstring.data()); + EXPECT_DEATH(sav[2], deathstring); } { @@ -482,35 +482,35 @@ TEST(strided_span_tests, strided_span_bounds) EXPECT_TRUE(sav.bounds().index_bounds() == multi_span_index<1>{2}); EXPECT_TRUE(sav[0] == 0); EXPECT_TRUE(sav[1] == 3); - EXPECT_DEATH(sav[2], deathstring.data()); + EXPECT_DEATH(sav[2], deathstring); } { // bounds cross data boundaries - from static arrays - EXPECT_DEATH((strided_span{arr, {3, 2}}), deathstring.data()); - EXPECT_DEATH((strided_span{arr, {3, 3}}), deathstring.data()); - EXPECT_DEATH((strided_span{arr, {4, 5}}), deathstring.data()); - EXPECT_DEATH((strided_span{arr, {5, 1}}), deathstring.data()); - EXPECT_DEATH((strided_span{arr, {5, 5}}), deathstring.data()); + EXPECT_DEATH((strided_span{arr, {3, 2}}), deathstring); + EXPECT_DEATH((strided_span{arr, {3, 3}}), deathstring); + EXPECT_DEATH((strided_span{arr, {4, 5}}), deathstring); + EXPECT_DEATH((strided_span{arr, {5, 1}}), deathstring); + EXPECT_DEATH((strided_span{arr, {5, 5}}), deathstring); } { // bounds cross data boundaries - from array view - EXPECT_DEATH((strided_span{av, {3, 2}}), deathstring.data()); - EXPECT_DEATH((strided_span{av, {3, 3}}), deathstring.data()); - EXPECT_DEATH((strided_span{av, {4, 5}}), deathstring.data()); - EXPECT_DEATH((strided_span{av, {5, 1}}), deathstring.data()); - EXPECT_DEATH((strided_span{av, {5, 5}}), deathstring.data()); + EXPECT_DEATH((strided_span{av, {3, 2}}), deathstring); + EXPECT_DEATH((strided_span{av, {3, 3}}), deathstring); + EXPECT_DEATH((strided_span{av, {4, 5}}), deathstring); + EXPECT_DEATH((strided_span{av, {5, 1}}), deathstring); + EXPECT_DEATH((strided_span{av, {5, 5}}), deathstring); } { // bounds cross data boundaries - from dynamic arrays - EXPECT_DEATH((strided_span{av.data(), 4, {3, 2}}), deathstring.data()); - EXPECT_DEATH((strided_span{av.data(), 4, {3, 3}}), deathstring.data()); - EXPECT_DEATH((strided_span{av.data(), 4, {4, 5}}), deathstring.data()); - EXPECT_DEATH((strided_span{av.data(), 4, {5, 1}}), deathstring.data()); - EXPECT_DEATH((strided_span{av.data(), 4, {5, 5}}), deathstring.data()); - EXPECT_DEATH((strided_span{av.data(), 2, {2, 2}}), deathstring.data()); + EXPECT_DEATH((strided_span{av.data(), 4, {3, 2}}), deathstring); + EXPECT_DEATH((strided_span{av.data(), 4, {3, 3}}), deathstring); + EXPECT_DEATH((strided_span{av.data(), 4, {4, 5}}), deathstring); + EXPECT_DEATH((strided_span{av.data(), 4, {5, 1}}), deathstring); + EXPECT_DEATH((strided_span{av.data(), 4, {5, 5}}), deathstring); + EXPECT_DEATH((strided_span{av.data(), 2, {2, 2}}), deathstring); } #ifdef CONFIRM_COMPILATION_ERRORS @@ -569,8 +569,8 @@ TEST(strided_span_tests, strided_span_type_conversion) strided_span sav3 = sav2.as_strided_span(); EXPECT_TRUE(sav3[0][0] == 0); EXPECT_TRUE(sav3[1][0] == 2); - EXPECT_DEATH(sav3[1][1], deathstring.data()); - EXPECT_DEATH(sav3[0][1], deathstring.data()); + EXPECT_DEATH(sav3[1][1], deathstring); + EXPECT_DEATH(sav3[0][1], deathstring); } // retype strided array with regular strides - from multi_span @@ -582,8 +582,8 @@ TEST(strided_span_tests, strided_span_type_conversion) strided_span sav3 = sav2.as_strided_span(); EXPECT_TRUE(sav3[0][0] == 0); EXPECT_TRUE(sav3[1][0] == 2); - EXPECT_DEATH(sav3[1][1], deathstring.data()); - EXPECT_DEATH(sav3[0][1], deathstring.data()); + EXPECT_DEATH(sav3[1][1], deathstring); + EXPECT_DEATH(sav3[0][1], deathstring); } // retype strided array with not enough elements - last dimension of the array is too small @@ -592,7 +592,7 @@ TEST(strided_span_tests, strided_span_type_conversion) multi_span bytes2 = as_multi_span(bytes, dim<2>(), dim(bytes.size() / 2)); strided_span sav2{bytes2, bounds}; - EXPECT_DEATH(sav2.as_strided_span(), deathstring.data()); + EXPECT_DEATH(sav2.as_strided_span(), deathstring); } // retype strided array with not enough elements - strides are too small @@ -601,7 +601,7 @@ TEST(strided_span_tests, strided_span_type_conversion) multi_span bytes2 = as_multi_span(bytes, dim<2>(), dim(bytes.size() / 2)); strided_span sav2{bytes2, bounds}; - EXPECT_DEATH(sav2.as_strided_span(), deathstring.data()); + EXPECT_DEATH(sav2.as_strided_span(), deathstring); } // retype strided array with not enough elements - last dimension does not divide by the new @@ -611,7 +611,7 @@ TEST(strided_span_tests, strided_span_type_conversion) multi_span bytes2 = as_multi_span(bytes, dim<2>(), dim(bytes.size() / 2)); strided_span sav2{bytes2, bounds}; - EXPECT_DEATH(sav2.as_strided_span(), deathstring.data()); + EXPECT_DEATH(sav2.as_strided_span(), deathstring); } // retype strided array with not enough elements - strides does not divide by the new @@ -621,21 +621,21 @@ TEST(strided_span_tests, strided_span_type_conversion) multi_span bytes2 = as_multi_span(bytes, dim<2>(), dim(bytes.size() / 2)); strided_span sav2{bytes2, bounds}; - EXPECT_DEATH(sav2.as_strided_span(), deathstring.data()); + EXPECT_DEATH(sav2.as_strided_span(), deathstring); } // retype strided array with irregular strides - from raw data { strided_bounds<1> bounds{bytes.size() / 2, 2}; strided_span sav2{bytes.data(), bytes.size(), bounds}; - EXPECT_DEATH(sav2.as_strided_span(), deathstring.data()); + EXPECT_DEATH(sav2.as_strided_span(), deathstring); } // retype strided array with irregular strides - from multi_span { strided_bounds<1> bounds{bytes.size() / 2, 2}; strided_span sav2{bytes, bounds}; - EXPECT_DEATH(sav2.as_strided_span(), deathstring.data()); + EXPECT_DEATH(sav2.as_strided_span(), deathstring); } } @@ -652,9 +652,9 @@ TEST(strided_span_tests, empty_strided_spans) EXPECT_TRUE(empty_sav.bounds().index_bounds() == multi_span_index<1>{0}); EXPECT_TRUE(empty_sav.empty()); - EXPECT_DEATH(empty_sav[0], deathstring.data()); - EXPECT_DEATH(empty_sav.begin()[0], deathstring.data()); - EXPECT_DEATH(empty_sav.cbegin()[0], deathstring.data()); + EXPECT_DEATH(empty_sav[0], deathstring); + EXPECT_DEATH(empty_sav.begin()[0], deathstring); + EXPECT_DEATH(empty_sav.cbegin()[0], deathstring); for (const auto& v : empty_sav) { (void) v; @@ -666,9 +666,9 @@ TEST(strided_span_tests, empty_strided_spans) strided_span empty_sav{nullptr, 0, {0, 1}}; EXPECT_TRUE(empty_sav.bounds().index_bounds() == multi_span_index<1>{0}); - EXPECT_DEATH(empty_sav[0], deathstring.data()); - EXPECT_DEATH(empty_sav.begin()[0], deathstring.data()); - EXPECT_DEATH(empty_sav.cbegin()[0], deathstring.data()); + EXPECT_DEATH(empty_sav[0], deathstring); + EXPECT_DEATH(empty_sav.begin()[0], deathstring); + EXPECT_DEATH(empty_sav.cbegin()[0], deathstring); for (const auto& v : empty_sav) { (void) v; @@ -760,7 +760,7 @@ TEST(strided_span_tests, strided_span_conversion) std::cerr << "Expected Death. strided_span_conversion"; std::abort(); }); - + // get an multi_span of 'c' values from the list of X's struct X @@ -804,7 +804,7 @@ TEST(strided_span_tests, strided_span_conversion) strided_span result = transposed[0]; EXPECT_TRUE(result.bounds().index_bounds()[0] == 4); - EXPECT_DEATH(result.bounds().index_bounds()[1], deathstring.data()); + EXPECT_DEATH(result.bounds().index_bounds()[1], deathstring); int i = 0; for (auto& num : result) { diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp index 64f7ea0..386834c 100644 --- a/tests/string_span_tests.cpp +++ b/tests/string_span_tests.cpp @@ -72,7 +72,7 @@ auto strnlen(const CharT* s, std::size_t n) namespace { -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); template T move_wrapper(T&& t) @@ -988,7 +988,7 @@ TEST(string_span_tests, zstring) buf[0] = 'a'; auto workaround_macro = [&]() { const zstring_span<> zspan({buf, 1}); }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } // usage scenario: create zero-terminated temp file name and pass to a legacy API @@ -1010,7 +1010,7 @@ TEST(string_span_tests, wzstring) std::cerr << "Expected Death. wzstring"; std::abort(); }); - + // create zspan from zero terminated string { wchar_t buf[1]; @@ -1029,7 +1029,7 @@ TEST(string_span_tests, wzstring) buf[0] = L'a'; const auto workaround_macro = [&]() { const wzstring_span<> zspan({buf, 1}); }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } // usage scenario: create zero-terminated temp file name and pass to a legacy API @@ -1070,7 +1070,7 @@ TEST(string_span_tests, u16zstring) buf[0] = u'a'; const auto workaround_macro = [&]() { const u16zstring_span<> zspan({buf, 1}); }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } // usage scenario: create zero-terminated temp file name and pass to a legacy API @@ -1111,7 +1111,7 @@ TEST(string_span_tests, u32zstring) buf[0] = u'a'; const auto workaround_macro = [&]() { const u32zstring_span<> zspan({buf, 1}); }; - EXPECT_DEATH(workaround_macro(), deathstring.data()); + EXPECT_DEATH(workaround_macro(), deathstring); } // usage scenario: create zero-terminated temp file name and pass to a legacy API diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index 6393da4..6e6dd8a 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -45,7 +45,7 @@ using namespace gsl; namespace{ -constexpr std::string_view deathstring("Expected Death"); +static const std::string deathstring("Expected Death"); void f(int& i) { i += 1; } static int j = 0; void g() { j += 1; } @@ -124,13 +124,13 @@ TEST(utils_tests, narrow) std::cerr << "Expected Death. narrow"; std::abort(); }); - + int n = 120; const char c = narrow(n); EXPECT_TRUE(c == 120); n = 300; - EXPECT_DEATH(narrow(n), deathstring.data()); + EXPECT_DEATH(narrow(n), deathstring); const auto int32_max = std::numeric_limits::max(); const auto int32_min = std::numeric_limits::min(); @@ -139,11 +139,11 @@ TEST(utils_tests, narrow) EXPECT_TRUE(narrow(int32_t(1)) == 1); EXPECT_TRUE(narrow(int32_max) == static_cast(int32_max)); - EXPECT_DEATH(narrow(int32_t(-1)), deathstring.data()); - EXPECT_DEATH(narrow(int32_min), deathstring.data()); + EXPECT_DEATH(narrow(int32_t(-1)), deathstring); + EXPECT_DEATH(narrow(int32_min), deathstring); n = -42; - EXPECT_DEATH(narrow(n), deathstring.data()); + EXPECT_DEATH(narrow(n), deathstring); #if GSL_CONSTEXPR_NARROW static_assert(narrow(120) == 120, "Fix GSL_CONSTEXPR_NARROW");