From b39a9732f8e5eca21998bf8e1cef7698b20de320 Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Wed, 4 Dec 2019 13:46:50 -0800 Subject: [PATCH] attempting to fix the gtest print issues in vs17 --- tests/algorithm_tests.cpp | 32 +- tests/assertion_tests.cpp | 4 +- tests/at_tests.cpp | 16 +- tests/bounds_tests.cpp | 4 +- tests/multi_span_tests.cpp | 646 ++++++++++++++-------------- tests/notnull_tests.cpp | 134 +++--- tests/owner_tests.cpp | 4 +- tests/span_tests.cpp | 751 +++++++++++++++++---------------- tests/strict_notnull_tests.cpp | 24 +- tests/strided_span_tests.cpp | 16 +- tests/string_span_tests.cpp | 430 +++++++++---------- tests/utils_tests.cpp | 28 +- 12 files changed, 1060 insertions(+), 1029 deletions(-) diff --git a/tests/algorithm_tests.cpp b/tests/algorithm_tests.cpp index e00e688..7ba81b5 100644 --- a/tests/algorithm_tests.cpp +++ b/tests/algorithm_tests.cpp @@ -57,8 +57,8 @@ TEST(algorithm_tests, same_type) copy(src_span, dst_span.subspan(src_span.size())); for (std::size_t i = 0; i < src.size(); ++i) { - EXPECT_EQ(dst[i], src[i]); - EXPECT_EQ(dst[i + src.size()], src[i]); + EXPECT_TRUE(dst[i] == src[i]); + EXPECT_TRUE(dst[i + src.size()] == src[i]); } } @@ -74,8 +74,8 @@ TEST(algorithm_tests, same_type) copy(src_span, dst_span.subspan(src_span.size())); for (std::size_t i = 0; i < src.size(); ++i) { - EXPECT_EQ(dst[i], src[i]); - EXPECT_EQ(dst[i + src.size()], src[i]); + EXPECT_TRUE(dst[i] == src[i]); + EXPECT_TRUE(dst[i + src.size()] == src[i]); } } @@ -91,8 +91,8 @@ TEST(algorithm_tests, same_type) copy(src_span, dst_span.subspan(src_span.size())); for (std::size_t i = 0; i < src.size(); ++i) { - EXPECT_EQ(dst[i], src[i]); - EXPECT_EQ(dst[i + src.size()], src[i]); + EXPECT_TRUE(dst[i] == src[i]); + EXPECT_TRUE(dst[i + src.size()] == src[i]); } } @@ -108,8 +108,8 @@ TEST(algorithm_tests, same_type) copy(src_span, dst_span.subspan(src_span.size())); for (std::size_t i = 0; i < src.size(); ++i) { - EXPECT_EQ(dst[i], src[i]); - EXPECT_EQ(dst[i + src.size()], src[i]); + EXPECT_TRUE(dst[i] == src[i]); + EXPECT_TRUE(dst[i + src.size()] == src[i]); } } } @@ -128,8 +128,8 @@ TEST(algorithm_tests, compatible_type) copy(src_span, dst_span.subspan(src_span.size())); for (std::size_t i = 0; i < src.size(); ++i) { - EXPECT_EQ(dst[i], src[i]); - EXPECT_EQ(dst[i + src.size()], src[i]); + EXPECT_TRUE(dst[i] == src[i]); + EXPECT_TRUE(dst[i + src.size()] == src[i]); } } @@ -145,8 +145,8 @@ TEST(algorithm_tests, compatible_type) copy(src_span, dst_span.subspan(src_span.size())); for (std::size_t i = 0; i < src.size(); ++i) { - EXPECT_EQ(dst[i], src[i]); - EXPECT_EQ(dst[i + src.size()], src[i]); + EXPECT_TRUE(dst[i] == src[i]); + EXPECT_TRUE(dst[i + src.size()] == src[i]); } } @@ -162,8 +162,8 @@ TEST(algorithm_tests, compatible_type) copy(src_span, dst_span.subspan(src_span.size())); for (std::size_t i = 0; i < src.size(); ++i) { - EXPECT_EQ(dst[i], src[i]); - EXPECT_EQ(dst[i + src.size()], src[i]); + EXPECT_TRUE(dst[i] == src[i]); + EXPECT_TRUE(dst[i + src.size()] == src[i]); } } @@ -179,8 +179,8 @@ TEST(algorithm_tests, compatible_type) copy(src_span, dst_span.subspan(src_span.size())); for (std::size_t i = 0; i < src.size(); ++i) { - EXPECT_EQ(dst[i], src[i]); - EXPECT_EQ(dst[i + src.size()], src[i]); + EXPECT_TRUE(dst[i] == src[i]); + EXPECT_TRUE(dst[i + src.size()] == src[i]); } } } diff --git a/tests/assertion_tests.cpp b/tests/assertion_tests.cpp index 1584bcd..c548d13 100644 --- a/tests/assertion_tests.cpp +++ b/tests/assertion_tests.cpp @@ -53,14 +53,14 @@ int g(int i) TEST(assertion_tests, expects) { - EXPECT_EQ(f(2), 2); + EXPECT_TRUE(f(2) == 2); EXPECT_DEATH(f(10), ".*"); } TEST(assertion_tests, ensures) { - EXPECT_EQ(g(2), 3); + EXPECT_TRUE(g(2) == 3); EXPECT_DEATH(g(9), ".*"); } diff --git a/tests/at_tests.cpp b/tests/at_tests.cpp index 0f7e3d9..76ce444 100644 --- a/tests/at_tests.cpp +++ b/tests/at_tests.cpp @@ -44,8 +44,8 @@ TEST(at_tests, static_array) const int(&c_a)[4] = a; for (int i = 0; i < 4; ++i) { - EXPECT_EQ(&gsl::at(a, i), &a[i]); - EXPECT_EQ(&gsl::at(c_a, i), &a[i]); + EXPECT_TRUE(&gsl::at(a, i) == &a[i]); + EXPECT_TRUE(&gsl::at(c_a, i) == &a[i]); } EXPECT_DEATH(gsl::at(a, -1), ".*"); @@ -60,8 +60,8 @@ TEST(at_tests, std_array) const std::array& c_a = a; for (int i = 0; i < 4; ++i) { - EXPECT_EQ(&gsl::at(a, i), &a[static_cast(i)]); - EXPECT_EQ(&gsl::at(c_a, i), &a[static_cast(i)]); + EXPECT_TRUE(&gsl::at(a, i) == &a[static_cast(i)]); + EXPECT_TRUE(&gsl::at(c_a, i) == &a[static_cast(i)]); } EXPECT_DEATH(gsl::at(a, -1), ".*"); @@ -76,8 +76,8 @@ TEST(at_tests, StdVector) const std::vector& c_a = a; for (int i = 0; i < 4; ++i) { - EXPECT_EQ(&gsl::at(a, i), &a[static_cast(i)]); - EXPECT_EQ(&gsl::at(c_a, i), &a[static_cast(i)]); + EXPECT_TRUE(&gsl::at(a, i) == &a[static_cast(i)]); + EXPECT_TRUE(&gsl::at(c_a, i) == &a[static_cast(i)]); } EXPECT_DEATH(gsl::at(a, -1), ".*"); @@ -91,8 +91,8 @@ TEST(at_tests, InitializerList) const std::initializer_list a = {1, 2, 3, 4}; for (int i = 0; i < 4; ++i) { - EXPECT_EQ(gsl::at(a, i), i + 1); - EXPECT_EQ(gsl::at({1, 2, 3, 4}, i), i + 1); + EXPECT_TRUE(gsl::at(a, i) == i + 1); + EXPECT_TRUE(gsl::at({1, 2, 3, 4}, i) == i + 1); } EXPECT_DEATH(gsl::at(a, -1), ".*"); diff --git a/tests/bounds_tests.cpp b/tests/bounds_tests.cpp index 725127f..f76dbac 100644 --- a/tests/bounds_tests.cpp +++ b/tests/bounds_tests.cpp @@ -110,8 +110,8 @@ TEST(bounds_tests, bounds_convertible) b5 = static_bounds<34>(); b6 = b5; - EXPECT_EQ(b5, b6); - EXPECT_EQ(b5.size(), b6.size()); + EXPECT_TRUE(b5 == b6); + EXPECT_TRUE(b5.size() == b6.size()); } #ifdef CONFIRM_COMPILATION_ERRORS diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index 702b021..8f5a1ef 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -68,12 +68,12 @@ struct DerivedClass : BaseClass void overloaded_func(multi_span exp, int expected_value) { - for (auto val : exp) { EXPECT_EQ(val, expected_value); } + for (auto val : exp) { EXPECT_TRUE(val == expected_value); } } void overloaded_func(multi_span exp, char expected_value) { - for (auto val : exp) { EXPECT_EQ(val, expected_value); } + for (auto val : exp) { EXPECT_TRUE(val == expected_value); } } void iterate_second_column(multi_span av) @@ -83,23 +83,23 @@ void iterate_second_column(multi_span av) // view to the second column auto section = av.section({0, 1}, {length, 1}); - EXPECT_EQ(section.size(), length); - for (auto i = 0; i < section.size(); ++i) { EXPECT_EQ(section[i][0], av[i][1]); } + EXPECT_TRUE(section.size() == length); + for (auto i = 0; i < section.size(); ++i) { EXPECT_TRUE(section[i][0] == av[i][1]); } for (auto i = 0; i < section.size(); ++i) { auto idx = multi_span_index<2>{i, 0}; // avoid braces inside the CHECK macro - EXPECT_EQ(section[idx], av[i][1]); + EXPECT_TRUE(section[idx] == av[i][1]); } - EXPECT_EQ(section.bounds().index_bounds()[0], length); - EXPECT_EQ(section.bounds().index_bounds()[1], 1); + EXPECT_TRUE(section.bounds().index_bounds()[0] == length); + EXPECT_TRUE(section.bounds().index_bounds()[1] == 1); for (auto i = 0; i < section.bounds().index_bounds()[0]; ++i) { for (auto j = 0; j < section.bounds().index_bounds()[1]; ++j) { auto idx = multi_span_index<2>{i, j}; // avoid braces inside the CHECK macro - EXPECT_EQ(section[idx], av[i][1]); + EXPECT_TRUE(section[idx] == av[i][1]); } } @@ -111,24 +111,24 @@ void iterate_second_column(multi_span av) auto sum = 0; for (auto num : section) { - EXPECT_EQ(num, av[idx][1]); + EXPECT_TRUE(num == av[idx][1]); sum += num; idx++; } - EXPECT_EQ(sum, check_sum); + EXPECT_TRUE(sum == check_sum); } { auto idx = length - 1; auto sum = 0; for (auto iter = section.rbegin(); iter != section.rend(); ++iter) { - EXPECT_EQ(*iter, av[idx][1]); + EXPECT_TRUE(*iter == av[idx][1]); sum += *iter; idx--; } - EXPECT_EQ(sum, check_sum); + EXPECT_TRUE(sum == check_sum); } } template @@ -142,40 +142,40 @@ TEST(multi_span_test, default_constructor) { { multi_span s; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } { multi_span s; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } { #ifdef CONFIRM_COMPILATION_ERRORS multi_span s; - EXPECT_EQ(s.length(), 1); - EXPECT_EQ(s.data(), nullptr); // explains why it can't compile + EXPECT_TRUE(s.length() == 1); + EXPECT_TRUE(s.data() == nullptr); // explains why it can't compile #endif } { multi_span s{}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs{}; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } } @@ -183,72 +183,72 @@ TEST(multi_span_test, from_nullptr_constructor) { { multi_span s = nullptr; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs = nullptr; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } { multi_span s = nullptr; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs = nullptr; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } { #ifdef CONFIRM_COMPILATION_ERRORS multi_span s = nullptr; - EXPECT_EQ(s.length(), 1); - EXPECT_EQ(s.data(), nullptr); // explains why it can't compile + EXPECT_TRUE(s.length() == 1); + EXPECT_TRUE(s.data() == nullptr); // explains why it can't compile #endif } { multi_span s{nullptr}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs{nullptr}; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } { multi_span s{nullptr}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs{nullptr}; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } } TEST(multi_span_test, from_nullptr_length_constructor) { { multi_span s{nullptr, 0}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs{nullptr, 0}; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } { multi_span s{nullptr, 0}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs{nullptr, 0}; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } { @@ -269,19 +269,19 @@ TEST(multi_span_test, from_nullptr_length_constructor) { { multi_span s{nullptr, 0}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); multi_span cs{nullptr, 0}; - EXPECT_EQ(cs.length(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.length() == 0); + EXPECT_TRUE(cs.data() == nullptr); } { #ifdef CONFIRM_COMPILATION_ERRORS multi_span s{nullptr, 0}; - EXPECT_EQ(s.length(), 1); - EXPECT_EQ(s.data(), nullptr); // explains why it can't compile + EXPECT_TRUE(s.length() == 1); + EXPECT_TRUE(s.data() == nullptr); // explains why it can't compile #endif } } @@ -292,14 +292,14 @@ TEST(multi_span_test, from_element_constructor) { multi_span s = i; - EXPECT_EQ(s.length(), 1); - EXPECT_EQ(s.data(), &i); - EXPECT_EQ(s[0], 5); + EXPECT_TRUE(s.length() == 1); + EXPECT_TRUE(s.data() == &i); + EXPECT_TRUE(s[0] == 5); multi_span cs = i; - EXPECT_EQ(cs.length(), 1); - EXPECT_EQ(cs.data(), &i); - EXPECT_EQ(cs[0], 5); + EXPECT_TRUE(cs.length() == 1); + EXPECT_TRUE(cs.data() == &i); + EXPECT_TRUE(cs[0] == 5); } { @@ -312,23 +312,23 @@ TEST(multi_span_test, from_element_constructor) { #ifdef CONFIRM_COMPILATION_ERRORS multi_span s = i; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), &i); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == &i); #endif } { multi_span s = i; - EXPECT_EQ(s.length(), 1); - EXPECT_EQ(s.data(), &i); - EXPECT_EQ(s[0], 5); + EXPECT_TRUE(s.length() == 1); + EXPECT_TRUE(s.data() == &i); + EXPECT_TRUE(s[0] == 5); } { #ifdef CONFIRM_COMPILATION_ERRORS multi_span s = i; - EXPECT_EQ(s.length(), 2); - EXPECT_EQ(s.data(), &i); + EXPECT_TRUE(s.length() == 2); + EXPECT_TRUE(s.data() == &i); #endif } @@ -347,25 +347,25 @@ TEST(multi_span_test, from_pointer_length_constructor) { multi_span s{&arr[0], 2}; - EXPECT_EQ(s.length(), 2); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[1], 2); + EXPECT_TRUE(s.length() == 2); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[1] == 2); } { multi_span s{&arr[0], 2}; - EXPECT_EQ(s.length(), 2); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[1], 2); + EXPECT_TRUE(s.length() == 2); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[1] == 2); } { int* p = nullptr; multi_span s{p, 0}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == nullptr); } { @@ -381,30 +381,30 @@ TEST(multi_span_test, from_pointer_pointer_constructor) { multi_span s{&arr[0], &arr[2]}; - EXPECT_EQ(s.length(), 2); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[1], 2); + EXPECT_TRUE(s.length() == 2); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[1] == 2); } { multi_span s{&arr[0], &arr[2]}; - EXPECT_EQ(s.length(), 2); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[1], 2); + EXPECT_TRUE(s.length() == 2); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[1] == 2); } { multi_span s{&arr[0], &arr[0]}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == &arr[0]); } { multi_span s{&arr[0], &arr[0]}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == &arr[0]); } { @@ -437,14 +437,14 @@ TEST(multi_span_test, from_array_constructor) { multi_span s{arr}; - EXPECT_EQ(s.length(), 5); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.length() == 5); + EXPECT_TRUE(s.data() == &arr[0]); } { multi_span s{arr}; - EXPECT_EQ(s.length(), 5); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.length() == 5); + EXPECT_TRUE(s.data() == &arr[0]); } { @@ -455,24 +455,24 @@ TEST(multi_span_test, from_array_constructor) { multi_span s{arr}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == &arr[0]); } int arr2d[2][3] = {1, 2, 3, 4, 5, 6}; { multi_span s{arr2d}; - EXPECT_EQ(s.length(), 6); - EXPECT_EQ(s.data(), &arr2d[0][0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[5], 6); + EXPECT_TRUE(s.length() == 6); + EXPECT_TRUE(s.data() == &arr2d[0][0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[5] == 6); } { multi_span s{arr2d}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), &arr2d[0][0]); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == &arr2d[0][0]); } { @@ -483,10 +483,10 @@ TEST(multi_span_test, from_array_constructor) { multi_span s{arr2d}; - EXPECT_EQ(s.length(), 6); - EXPECT_EQ(s.data(), &arr2d[0][0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[5], 6); + EXPECT_TRUE(s.length() == 6); + EXPECT_TRUE(s.data() == &arr2d[0][0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[5] == 6); } { @@ -497,14 +497,14 @@ TEST(multi_span_test, from_array_constructor) { multi_span s{arr2d[0]}; - EXPECT_EQ(s.length(), 1); - EXPECT_EQ(s.data(), &arr2d[0]); + EXPECT_TRUE(s.length() == 1); + EXPECT_TRUE(s.data() == &arr2d[0]); } { multi_span s{arr2d}; - EXPECT_EQ(s.length(), 6); - EXPECT_EQ(s.data(), &arr2d[0][0]); + EXPECT_TRUE(s.length() == 6); + EXPECT_TRUE(s.data() == &arr2d[0][0]); auto workaround_macro = [&]() { return s[{1, 2}] == 6; }; EXPECT_TRUE(workaround_macro()); } @@ -519,16 +519,16 @@ TEST(multi_span_test, from_array_constructor) { multi_span s{arr3d}; - EXPECT_EQ(s.length(), 12); - EXPECT_EQ(s.data(), &arr3d[0][0][0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[11], 12); + EXPECT_TRUE(s.length() == 12); + EXPECT_TRUE(s.data() == &arr3d[0][0][0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[11] == 12); } { multi_span s{arr3d}; - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), &arr3d[0][0][0]); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == &arr3d[0][0][0]); } { @@ -539,10 +539,10 @@ TEST(multi_span_test, from_array_constructor) { multi_span s{arr3d}; - EXPECT_EQ(s.length(), 12); - EXPECT_EQ(s.data(), &arr3d[0][0][0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[5], 6); + EXPECT_TRUE(s.length() == 12); + EXPECT_TRUE(s.data() == &arr3d[0][0][0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[5] == 6); } { @@ -553,14 +553,14 @@ TEST(multi_span_test, from_array_constructor) { multi_span s{arr3d[0]}; - EXPECT_EQ(s.length(), 1); - EXPECT_EQ(s.data(), &arr3d[0]); + EXPECT_TRUE(s.length() == 1); + EXPECT_TRUE(s.data() == &arr3d[0]); } { multi_span s{arr3d}; - EXPECT_EQ(s.length(), 12); - EXPECT_EQ(s.data(), &arr3d[0][0][0]); + EXPECT_TRUE(s.length() == 12); + EXPECT_TRUE(s.data() == &arr3d[0][0][0]); auto workaround_macro = [&]() { return s[{2, 1, 0}] == 11; }; EXPECT_TRUE(workaround_macro()); } @@ -578,27 +578,27 @@ TEST(multi_span_test, from_dynamic_array_constructor) { multi_span s(arr, 10); - EXPECT_EQ(s.length(), 120); - EXPECT_EQ(s.data(), &arr[0][0][0]); + EXPECT_TRUE(s.length() == 120); + EXPECT_TRUE(s.data() == &arr[0][0][0]); EXPECT_DEATH(s[10][3][4], ".*"); } { multi_span s(arr, 10); - EXPECT_EQ(s.length(), 120); - EXPECT_EQ(s.data(), &arr[0][0][0]); + EXPECT_TRUE(s.length() == 120); + EXPECT_TRUE(s.data() == &arr[0][0][0]); } { multi_span s(arr, 10); - EXPECT_EQ(s.length(), 120); - EXPECT_EQ(s.data(), &arr[0][0][0]); + EXPECT_TRUE(s.length() == 120); + EXPECT_TRUE(s.data() == &arr[0][0][0]); } { multi_span s(arr, 0); - EXPECT_EQ(s.length(), 0); - EXPECT_EQ(s.data(), &arr[0][0][0]); + EXPECT_TRUE(s.length() == 0); + EXPECT_TRUE(s.data() == &arr[0][0][0]); } delete[] arr; @@ -610,50 +610,50 @@ TEST(multi_span_test, from_std_array_constructor) { multi_span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); - EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); multi_span cs{arr}; - EXPECT_EQ(cs.size(), narrow_cast(arr.size())); - EXPECT_EQ(cs.data(), arr.data()); + EXPECT_TRUE(cs.size() == narrow_cast(arr.size())); + EXPECT_TRUE(cs.data() == arr.data()); } { multi_span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); - EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); multi_span cs{arr}; - EXPECT_EQ(cs.size(), narrow_cast(arr.size())); - EXPECT_EQ(cs.data(), arr.data()); + EXPECT_TRUE(cs.size() == narrow_cast(arr.size())); + EXPECT_TRUE(cs.data() == arr.data()); } { multi_span s{arr}; - EXPECT_EQ(s.size(), 2); - EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == arr.data()); multi_span cs{arr}; - EXPECT_EQ(cs.size(), 2); - EXPECT_EQ(cs.data(), arr.data()); + EXPECT_TRUE(cs.size() == 2); + EXPECT_TRUE(cs.data() == arr.data()); } { multi_span s{arr}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == arr.data()); multi_span cs{arr}; - EXPECT_EQ(cs.size(), 0); - EXPECT_EQ(cs.data(), arr.data()); + EXPECT_TRUE(cs.size() == 0); + EXPECT_TRUE(cs.data() == arr.data()); } // TODO This is currently an unsupported scenario. We will come back to it as we revise // the multidimensional interface and what transformations between dimensionality look like //{ // multi_span s{arr}; - // EXPECT_EQ(s.size(), narrow_cast(arr.size())); - // EXPECT_EQ(s.data(), arr.data()); + // EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + // EXPECT_TRUE(s.data() == arr.data()); //} { @@ -678,34 +678,34 @@ TEST(multi_span_test, from_const_std_array_constructor) { multi_span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); - EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); } { multi_span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); - EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); } { multi_span s{arr}; - EXPECT_EQ(s.size(), 2); - EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == arr.data()); } { multi_span s{arr}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == arr.data()); } // TODO This is currently an unsupported scenario. We will come back to it as we revise // the multidimensional interface and what transformations between dimensionality look like //{ // multi_span s{arr}; - // EXPECT_EQ(s.size(), narrow_cast(arr.size())); - // EXPECT_EQ(s.data(), arr.data()); + // EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + // EXPECT_TRUE(s.data() == arr.data()); //} { @@ -731,12 +731,12 @@ TEST(multi_span_test, from_container_constructor) { multi_span s{v}; - EXPECT_EQ(s.size(), narrow_cast(v.size())); - EXPECT_EQ(s.data(), v.data()); + EXPECT_TRUE(s.size() == narrow_cast(v.size())); + EXPECT_TRUE(s.data() == v.data()); multi_span cs{v}; - EXPECT_EQ(cs.size(), narrow_cast(v.size())); - EXPECT_EQ(cs.data(), v.data()); + EXPECT_TRUE(cs.size() == narrow_cast(v.size())); + EXPECT_TRUE(cs.data() == v.data()); } std::string str = "hello"; @@ -745,12 +745,12 @@ TEST(multi_span_test, from_container_constructor) { #ifdef CONFIRM_COMPILATION_ERRORS multi_span s{str}; - EXPECT_EQ(s.size(), narrow_cast(str.size())); - EXPECT_EQ(s.data(), str.data()); + EXPECT_TRUE(s.size() == narrow_cast(str.size())); + EXPECT_TRUE(s.data() == str.data()); #endif multi_span cs{str}; - EXPECT_EQ(cs.size(), narrow_cast(str.size())); - EXPECT_EQ(cs.data(), str.data()); + EXPECT_TRUE(cs.size() == narrow_cast(str.size())); + EXPECT_TRUE(cs.data() == str.data()); } { @@ -758,8 +758,8 @@ TEST(multi_span_test, from_container_constructor) multi_span s{cstr}; #endif multi_span cs{cstr}; - EXPECT_EQ(cs.size(), narrow_cast(cstr.size())); - EXPECT_EQ(cs.data(), cstr.data()); + EXPECT_TRUE(cs.size() == narrow_cast(cstr.size())); + EXPECT_TRUE(cs.data() == cstr.data()); } { @@ -837,22 +837,22 @@ TEST(multi_span_test, copy_move_and_assignment) int arr[] = {3, 4, 5}; multi_span s2 = arr; - EXPECT_EQ(s2.length(), 3); - EXPECT_EQ(s2.data(), &arr[0]); + EXPECT_TRUE(s2.length() == 3); + EXPECT_TRUE(s2.data() == &arr[0]); s2 = s1; EXPECT_TRUE(s2.empty()); auto get_temp_span = [&]() -> multi_span { return {&arr[1], 2}; }; auto use_span = [&](multi_span s) { - EXPECT_EQ(s.length(), 2); - EXPECT_EQ(s.data(), &arr[1]); + EXPECT_TRUE(s.length() == 2); + EXPECT_TRUE(s.data() == &arr[1]); }; use_span(get_temp_span()); s1 = get_temp_span(); - EXPECT_EQ(s1.length(), 2); - EXPECT_EQ(s1.data(), &arr[1]); + EXPECT_TRUE(s1.length() == 2); + EXPECT_TRUE(s1.data() == &arr[1]); } TEST(multi_span_test, as_multi_span_reshape) @@ -872,8 +872,8 @@ TEST(multi_span_test, as_multi_span_reshape) auto av8 = as_multi_span(av7); - EXPECT_EQ(av8.size(), av6.size()); - for (auto i = 0; i < av8.size(); i++) { EXPECT_EQ(av8[i], 1); } + EXPECT_TRUE(av8.size() == av6.size()); + for (auto i = 0; i < av8.size(); i++) { EXPECT_TRUE(av8[i] == 1); } } TEST(multi_span_test, first) @@ -882,40 +882,40 @@ TEST(multi_span_test, first) { multi_span av = arr; - EXPECT_EQ(av.first<2>().bounds(), static_bounds<2>()); - EXPECT_EQ(av.first<2>().length(), 2); - EXPECT_EQ(av.first(2).length(), 2); + EXPECT_TRUE(av.first<2>().bounds() == static_bounds<2>()); + EXPECT_TRUE(av.first<2>().length() == 2); + EXPECT_TRUE(av.first(2).length() == 2); } { multi_span av = arr; - EXPECT_EQ(av.first<0>().bounds(), static_bounds<0>()); - EXPECT_EQ(av.first<0>().length(), 0); - EXPECT_EQ(av.first(0).length(), 0); + EXPECT_TRUE(av.first<0>().bounds() == static_bounds<0>()); + EXPECT_TRUE(av.first<0>().length() == 0); + EXPECT_TRUE(av.first(0).length() == 0); } { multi_span av = arr; - EXPECT_EQ(av.first<5>().bounds(), static_bounds<5>()); - EXPECT_EQ(av.first<5>().length(), 5); - EXPECT_EQ(av.first(5).length(), 5); + EXPECT_TRUE(av.first<5>().bounds() == static_bounds<5>()); + EXPECT_TRUE(av.first<5>().length() == 5); + EXPECT_TRUE(av.first(5).length() == 5); } { multi_span av = arr; #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(av.first<6>().bounds(), static_bounds<6>()); - EXPECT_EQ(av.first<6>().length(), 6); - EXPECT_EQ(av.first<-1>().length(), -1); + EXPECT_TRUE(av.first<6>().bounds() == static_bounds<6>()); + EXPECT_TRUE(av.first<6>().length() == 6); + EXPECT_TRUE(av.first<-1>().length() == -1); #endif EXPECT_DEATH(av.first(6).length(), ".*"); } { multi_span av; - EXPECT_EQ(av.first<0>().bounds(), static_bounds<0>()); - EXPECT_EQ(av.first<0>().length(), 0); - EXPECT_EQ(av.first(0).length(), 0); + EXPECT_TRUE(av.first<0>().bounds() == static_bounds<0>()); + EXPECT_TRUE(av.first<0>().length() == 0); + EXPECT_TRUE(av.first(0).length() == 0); } } @@ -925,39 +925,39 @@ TEST(multi_span_test, last) { multi_span av = arr; - EXPECT_EQ(av.last<2>().bounds(), static_bounds<2>()); - EXPECT_EQ(av.last<2>().length(), 2); - EXPECT_EQ(av.last(2).length(), 2); + EXPECT_TRUE(av.last<2>().bounds() == static_bounds<2>()); + EXPECT_TRUE(av.last<2>().length() == 2); + EXPECT_TRUE(av.last(2).length() == 2); } { multi_span av = arr; - EXPECT_EQ(av.last<0>().bounds(), static_bounds<0>()); - EXPECT_EQ(av.last<0>().length(), 0); - EXPECT_EQ(av.last(0).length(), 0); + EXPECT_TRUE(av.last<0>().bounds() == static_bounds<0>()); + EXPECT_TRUE(av.last<0>().length() == 0); + EXPECT_TRUE(av.last(0).length() == 0); } { multi_span av = arr; - EXPECT_EQ(av.last<5>().bounds(), static_bounds<5>()); - EXPECT_EQ(av.last<5>().length(), 5); - EXPECT_EQ(av.last(5).length(), 5); + EXPECT_TRUE(av.last<5>().bounds() == static_bounds<5>()); + EXPECT_TRUE(av.last<5>().length() == 5); + EXPECT_TRUE(av.last(5).length() == 5); } { multi_span av = arr; #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(av.last<6>().bounds(), static_bounds<6>()); - EXPECT_EQ(av.last<6>().length(), 6); + EXPECT_TRUE(av.last<6>().bounds() == static_bounds<6>()); + EXPECT_TRUE(av.last<6>().length() == 6); #endif EXPECT_DEATH(av.last(6).length(), ".*"); } { multi_span av; - EXPECT_EQ(av.last<0>().bounds(), static_bounds<0>()); - EXPECT_EQ(av.last<0>().length(), 0); - EXPECT_EQ(av.last(0).length(), 0); + EXPECT_TRUE(av.last<0>().bounds() == static_bounds<0>()); + EXPECT_TRUE(av.last<0>().length() == 0); + EXPECT_TRUE(av.last(0).length() == 0); } } @@ -967,70 +967,70 @@ TEST(multi_span_test, subspan) { multi_span av = arr; - EXPECT_EQ((av.subspan<2, 2>().bounds()), static_bounds<2>()); - EXPECT_EQ((av.subspan<2, 2>().length()), 2); - EXPECT_EQ(av.subspan(2, 2).length(), 2); - EXPECT_EQ(av.subspan(2, 3).length(), 3); + EXPECT_TRUE((av.subspan<2, 2>().bounds()) == static_bounds<2>()); + EXPECT_TRUE((av.subspan<2, 2>().length()) == 2); + EXPECT_TRUE(av.subspan(2, 2).length() == 2); + EXPECT_TRUE(av.subspan(2, 3).length() == 3); } { multi_span av = arr; - EXPECT_EQ((av.subspan<0, 0>().bounds()), static_bounds<0>()); - EXPECT_EQ((av.subspan<0, 0>().length()), 0); - EXPECT_EQ(av.subspan(0, 0).length(), 0); + 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); } { multi_span av = arr; - EXPECT_EQ((av.subspan<0, 5>().bounds()), static_bounds<5>()); - EXPECT_EQ((av.subspan<0, 5>().length()), 5); - EXPECT_EQ(av.subspan(0, 5).length(), 5); + 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(), ".*"); EXPECT_DEATH(av.subspan(1, 5).length(), ".*"); } { multi_span av = arr; - EXPECT_EQ((av.subspan<5, 0>().bounds()), static_bounds<0>()); - EXPECT_EQ((av.subspan<5, 0>().length()), 0); - EXPECT_EQ(av.subspan(5, 0).length(), 0); + 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(), ".*"); } { multi_span av; - EXPECT_EQ((av.subspan<0, 0>().bounds()), static_bounds<0>()); - EXPECT_EQ((av.subspan<0, 0>().length()), 0); - EXPECT_EQ(av.subspan(0, 0).length(), 0); + 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()), ".*"); } { multi_span av; - EXPECT_EQ(av.subspan(0).length(), 0); + EXPECT_TRUE(av.subspan(0).length() == 0); EXPECT_DEATH(av.subspan(1).length(), ".*"); } { multi_span av = arr; - EXPECT_EQ(av.subspan(0).length(), 5); - EXPECT_EQ(av.subspan(1).length(), 4); - EXPECT_EQ(av.subspan(4).length(), 1); - EXPECT_EQ(av.subspan(5).length(), 0); + EXPECT_TRUE(av.subspan(0).length() == 5); + 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(), ".*"); auto av2 = av.subspan(1); - for (int i = 0; i < 4; ++i) EXPECT_EQ(av2[i], i + 2); + for (int i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); } { multi_span av = arr; - EXPECT_EQ(av.subspan(0).length(), 5); - EXPECT_EQ(av.subspan(1).length(), 4); - EXPECT_EQ(av.subspan(4).length(), 1); - EXPECT_EQ(av.subspan(5).length(), 0); + EXPECT_TRUE(av.subspan(0).length() == 5); + 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(), ".*"); auto av2 = av.subspan(1); - for (int i = 0; i < 4; ++i) EXPECT_EQ(av2[i], i + 2); + for (int i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); } } @@ -1040,18 +1040,18 @@ TEST(multi_span_test, rank) { multi_span s; - EXPECT_EQ(s.rank(), static_cast(1)); + EXPECT_TRUE(s.rank() == static_cast(1)); } { multi_span s = arr; - EXPECT_EQ(s.rank(), static_cast(1)); + EXPECT_TRUE(s.rank() == static_cast(1)); } int arr2d[1][1] = {}; { multi_span s = arr2d; - EXPECT_EQ(s.rank(), static_cast(2)); + EXPECT_TRUE(s.rank() == static_cast(2)); } } @@ -1059,18 +1059,18 @@ TEST(multi_span_test, extent) { { multi_span s; - EXPECT_EQ(s.extent(), 0); - EXPECT_EQ(s.extent(0), 0); + EXPECT_TRUE(s.extent() == 0); + EXPECT_TRUE(s.extent(0) == 0); EXPECT_DEATH(s.extent(1), ".*"); #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(s.extent<1>(), 0); + EXPECT_TRUE(s.extent<1>() == 0); #endif } { multi_span s; - EXPECT_EQ(s.extent(), 0); - EXPECT_EQ(s.extent(0), 0); + EXPECT_TRUE(s.extent() == 0); + EXPECT_TRUE(s.extent(0) == 0); EXPECT_DEATH(s.extent(1), ".*"); } @@ -1078,11 +1078,11 @@ TEST(multi_span_test, extent) int arr2d[1][2] = {}; multi_span s = arr2d; - EXPECT_EQ(s.extent(), 1); - EXPECT_EQ(s.extent<0>(), 1); - EXPECT_EQ(s.extent<1>(), 2); - EXPECT_EQ(s.extent(0), 1); - EXPECT_EQ(s.extent(1), 2); + EXPECT_TRUE(s.extent() == 1); + EXPECT_TRUE(s.extent<0>() == 1); + EXPECT_TRUE(s.extent<1>() == 2); + EXPECT_TRUE(s.extent(0) == 1); + EXPECT_TRUE(s.extent(1) == 2); EXPECT_DEATH(s.extent(3), ".*"); } @@ -1090,11 +1090,11 @@ TEST(multi_span_test, extent) int arr2d[1][2] = {}; multi_span s = arr2d; - EXPECT_EQ(s.extent(), 0); - EXPECT_EQ(s.extent<0>(), 0); - EXPECT_EQ(s.extent<1>(), 2); - EXPECT_EQ(s.extent(0), 0); - EXPECT_EQ(s.extent(1), 2); + EXPECT_TRUE(s.extent() == 0); + EXPECT_TRUE(s.extent<0>() == 0); + EXPECT_TRUE(s.extent<1>() == 2); + EXPECT_TRUE(s.extent(0) == 0); + EXPECT_TRUE(s.extent(1) == 2); EXPECT_DEATH(s.extent(3), ".*"); } } @@ -1105,7 +1105,7 @@ TEST(multi_span_test, operator_function_call) { multi_span s = arr; - EXPECT_EQ(s(0), 1); + EXPECT_TRUE(s(0) == 1); EXPECT_DEATH(s(5), ".*"); } @@ -1113,17 +1113,17 @@ TEST(multi_span_test, operator_function_call) { multi_span s = arr2d; - EXPECT_EQ(s(0, 0), 1); - EXPECT_EQ(s(0, 1), 2); - EXPECT_EQ(s(1, 2), 6); + EXPECT_TRUE(s(0, 0) == 1); + EXPECT_TRUE(s(0, 1) == 2); + EXPECT_TRUE(s(1, 2) == 6); } int arr3d[2][2][2] = {1, 2, 3, 4, 5, 6, 7, 8}; { multi_span s = arr3d; - EXPECT_EQ(s(0, 0, 0), 1); - EXPECT_EQ(s(1, 1, 1), 8); + EXPECT_TRUE(s(0, 0, 0) == 1); + EXPECT_TRUE(s(1, 1, 1) == 8); } } @@ -1244,7 +1244,7 @@ TEST(multi_span_test, basics) { auto ptr = as_multi_span(new int[10], 10); fill(ptr.begin(), ptr.end(), 99); - for (int num : ptr) { EXPECT_EQ(num, 99); } + for (int num : ptr) { EXPECT_TRUE(num == 99); } delete[] ptr.data(); } @@ -1279,13 +1279,13 @@ TEST(multi_span_test, span_parameter_test) auto av = as_multi_span(data, 4); - EXPECT_EQ(av.size(), 60); + EXPECT_TRUE(av.size() == 60); fill(av.begin(), av.end(), 34); int count = 0; for_each(av.rbegin(), av.rend(), [&](int val) { count += val; }); - EXPECT_EQ(count, 34 * 60); + EXPECT_TRUE(count == 34 * 60); overloaded_func(av, 34); overloaded_func(as_multi_span(av, dim(4), dim(3), dim(5)), 34); @@ -1311,16 +1311,16 @@ TEST(multi_span_test, md_access) { for (auto j = 0; j < width; j++) { - EXPECT_EQ(expected + 1, image_view[i][j][0]); - EXPECT_EQ(expected + 2, image_view[i][j][1]); - EXPECT_EQ(expected + 3, image_view[i][j][2]); + EXPECT_TRUE(expected + 1 == image_view[i][j][0]); + EXPECT_TRUE(expected + 2 == image_view[i][j][1]); + EXPECT_TRUE(expected + 3 == image_view[i][j][2]); auto val = image_view[{i, j, 0}]; - EXPECT_EQ(expected + 1, val); + EXPECT_TRUE(expected + 1 == val); val = image_view[{i, j, 1}]; - EXPECT_EQ(expected + 2, val); + EXPECT_TRUE(expected + 2 == val); val = image_view[{i, j, 2}]; - EXPECT_EQ(expected + 3, val); + EXPECT_TRUE(expected + 3 == val); expected += 3; } @@ -1391,7 +1391,7 @@ TEST(multi_span_test, empty_spans) { multi_span empty_av(nullptr); - EXPECT_EQ(empty_av.bounds().index_bounds(), multi_span_index<1>{0}); + EXPECT_TRUE(empty_av.bounds().index_bounds() == multi_span_index<1>{0}); EXPECT_DEATH(empty_av[0], ".*"); EXPECT_DEATH(empty_av.begin()[0], ".*"); EXPECT_DEATH(empty_av.cbegin()[0], ".*"); @@ -1404,7 +1404,7 @@ TEST(multi_span_test, empty_spans) { multi_span empty_av = {}; - EXPECT_EQ(empty_av.bounds().index_bounds(), multi_span_index<1>{0}); + EXPECT_TRUE(empty_av.bounds().index_bounds() == multi_span_index<1>{0}); EXPECT_DEATH(empty_av[0], ".*"); EXPECT_DEATH(empty_av.begin()[0], ".*"); EXPECT_DEATH(empty_av.cbegin()[0], ".*"); @@ -1430,14 +1430,14 @@ TEST(multi_span_test, index_constructor) ptrdiff_t a[1] = {0}; multi_span_index<1> i = a; - EXPECT_EQ(av[i], 4); + EXPECT_TRUE(av[i] == 4); auto av2 = as_multi_span(av, dim<4>(), dim(2)); ptrdiff_t a2[2] = {0, 1}; multi_span_index<2> i2 = a2; - EXPECT_EQ(av2[i2], 0); - EXPECT_EQ(av2[0][i], 4); + EXPECT_TRUE(av2[i2] == 0); + EXPECT_TRUE(av2[0][i] == 4); delete[] arr; } @@ -1447,60 +1447,60 @@ TEST(multi_span_test, index_constructors) { // components of the same type multi_span_index<3> i1(0, 1, 2); - EXPECT_EQ(i1[0], 0); + EXPECT_TRUE(i1[0] == 0); // components of different types std::size_t c0 = 0; std::size_t c1 = 1; multi_span_index<3> i2(c0, c1, 2); - EXPECT_EQ(i2[0], 0); + EXPECT_TRUE(i2[0] == 0); // from array multi_span_index<3> i3 = {0, 1, 2}; - EXPECT_EQ(i3[0], 0); + EXPECT_TRUE(i3[0] == 0); // from other index of the same size type multi_span_index<3> i4 = i3; - EXPECT_EQ(i4[0], 0); + EXPECT_TRUE(i4[0] == 0); // default multi_span_index<3> i7; - EXPECT_EQ(i7[0], 0); + EXPECT_TRUE(i7[0] == 0); // default multi_span_index<3> i9 = {}; - EXPECT_EQ(i9[0], 0); + EXPECT_TRUE(i9[0] == 0); } { // components of the same type multi_span_index<1> i1(0); - EXPECT_EQ(i1[0], 0); + EXPECT_TRUE(i1[0] == 0); // components of different types std::size_t c0 = 0; multi_span_index<1> i2(c0); - EXPECT_EQ(i2[0], 0); + EXPECT_TRUE(i2[0] == 0); // from array multi_span_index<1> i3 = {0}; - EXPECT_EQ(i3[0], 0); + EXPECT_TRUE(i3[0] == 0); // from int multi_span_index<1> i4 = 0; - EXPECT_EQ(i4[0], 0); + EXPECT_TRUE(i4[0] == 0); // from other index of the same size type multi_span_index<1> i5 = i3; - EXPECT_EQ(i5[0], 0); + EXPECT_TRUE(i5[0] == 0); // default multi_span_index<1> i8; - EXPECT_EQ(i8[0], 0); + EXPECT_TRUE(i8[0] == 0); // default multi_span_index<1> i9 = {}; - EXPECT_EQ(i9[0], 0); + EXPECT_TRUE(i9[0] == 0); } #ifdef CONFIRM_COMPILATION_ERRORS @@ -1521,51 +1521,51 @@ TEST(multi_span_test, index_operations) multi_span_index<3> i = a; multi_span_index<3> j = b; - EXPECT_EQ(i[0], 0); - EXPECT_EQ(i[1], 1); - EXPECT_EQ(i[2], 2); + EXPECT_TRUE(i[0] == 0); + EXPECT_TRUE(i[1] == 1); + EXPECT_TRUE(i[2] == 2); { multi_span_index<3> k = i + j; - EXPECT_EQ(i[0], 0); - EXPECT_EQ(i[1], 1); - EXPECT_EQ(i[2], 2); - EXPECT_EQ(k[0], 3); - EXPECT_EQ(k[1], 5); - EXPECT_EQ(k[2], 7); + EXPECT_TRUE(i[0] == 0); + EXPECT_TRUE(i[1] == 1); + EXPECT_TRUE(i[2] == 2); + EXPECT_TRUE(k[0] == 3); + EXPECT_TRUE(k[1] == 5); + EXPECT_TRUE(k[2] == 7); } { multi_span_index<3> k = i * 3; - EXPECT_EQ(i[0], 0); - EXPECT_EQ(i[1], 1); - EXPECT_EQ(i[2], 2); - EXPECT_EQ(k[0], 0); - EXPECT_EQ(k[1], 3); - EXPECT_EQ(k[2], 6); + EXPECT_TRUE(i[0] == 0); + EXPECT_TRUE(i[1] == 1); + EXPECT_TRUE(i[2] == 2); + EXPECT_TRUE(k[0] == 0); + EXPECT_TRUE(k[1] == 3); + EXPECT_TRUE(k[2] == 6); } { multi_span_index<3> k = 3 * i; - EXPECT_EQ(i[0], 0); - EXPECT_EQ(i[1], 1); - EXPECT_EQ(i[2], 2); - EXPECT_EQ(k[0], 0); - EXPECT_EQ(k[1], 3); - EXPECT_EQ(k[2], 6); + EXPECT_TRUE(i[0] == 0); + EXPECT_TRUE(i[1] == 1); + EXPECT_TRUE(i[2] == 2); + EXPECT_TRUE(k[0] == 0); + EXPECT_TRUE(k[1] == 3); + EXPECT_TRUE(k[2] == 6); } { multi_span_index<2> k = details::shift_left(i); - EXPECT_EQ(i[0], 0); - EXPECT_EQ(i[1], 1); - EXPECT_EQ(i[2], 2); - EXPECT_EQ(k[0], 1); - EXPECT_EQ(k[1], 2); + EXPECT_TRUE(i[0] == 0); + EXPECT_TRUE(i[1] == 1); + EXPECT_TRUE(i[2] == 2); + EXPECT_TRUE(k[0] == 1); + EXPECT_TRUE(k[1] == 2); } } @@ -1635,7 +1635,7 @@ TEST(multi_span_test, span_structure_size) double* v1; ptrdiff_t v2; }; - EXPECT_EQ(sizeof(av1), sizeof(EffectiveStructure)); + EXPECT_TRUE(sizeof(av1) == sizeof(EffectiveStructure)); EXPECT_DEATH(av1[10][3][4], ".*"); @@ -1652,7 +1652,7 @@ TEST(multi_span_test, fixed_size_conversions) // converting to an multi_span from an equal size array is ok multi_span av4 = arr; - EXPECT_EQ(av4.length(), 4); + EXPECT_TRUE(av4.length() == 4); // converting to dynamic_range a_v is always ok { @@ -1757,16 +1757,16 @@ TEST(multi_span_test, as_writeable_bytes) { multi_span av; auto wav = as_writeable_bytes(av); - EXPECT_EQ(wav.length(), av.length()); - EXPECT_EQ(wav.length(), 0); - EXPECT_EQ(wav.size_bytes(), 0); + EXPECT_TRUE(wav.length() == av.length()); + EXPECT_TRUE(wav.length() == 0); + EXPECT_TRUE(wav.size_bytes() == 0); } { multi_span av = a; auto wav = as_writeable_bytes(av); - EXPECT_EQ(wav.data(), reinterpret_cast(&a[0])); - EXPECT_EQ(static_cast(wav.length()), sizeof(a)); + EXPECT_TRUE(wav.data() == reinterpret_cast(&a[0])); + EXPECT_TRUE(static_cast(wav.length()) == sizeof(a)); } } @@ -1787,7 +1787,7 @@ TEST(multi_span_test, iterator) } for (std::size_t i = 0; i < 4; ++i) { - EXPECT_EQ(a[i], 0); + EXPECT_TRUE(a[i] == 0); } } @@ -1797,7 +1797,7 @@ TEST(multi_span_test, iterator) n = 1; } for (std::size_t i = 0; i < 4; ++i) { - EXPECT_EQ(a[i], 1); + EXPECT_TRUE(a[i] == 1); } } } diff --git a/tests/notnull_tests.cpp b/tests/notnull_tests.cpp index 0c183c9..3982bdd 100644 --- a/tests/notnull_tests.cpp +++ b/tests/notnull_tests.cpp @@ -166,7 +166,7 @@ TEST(notnull_tests, TestNotNullConstructors) int i = 12; auto rp = RefCounted(&i); not_null p(rp); - EXPECT_EQ(p.get(), &i); + EXPECT_TRUE(p.get() == &i); not_null> x( std::make_shared(10)); // shared_ptr is nullptr assignable @@ -183,7 +183,7 @@ TEST(notnull_tests, TestNotNullConstructors) helper(&t); helper_const(&t); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { @@ -199,7 +199,7 @@ TEST(notnull_tests, TestNotNullConstructors) helper(x); helper_const(x); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { @@ -213,7 +213,7 @@ TEST(notnull_tests, TestNotNullConstructors) helper_const(cp); helper_const(x); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { @@ -223,7 +223,7 @@ TEST(notnull_tests, TestNotNullConstructors) auto x = not_null{cp}; - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { @@ -243,14 +243,14 @@ void ostream_helper(T v) std::ostringstream ref; os << static_cast(p); ref << static_cast(&v); - EXPECT_EQ(os.str(), ref.str()); + EXPECT_TRUE(os.str() == ref.str()); } { std::ostringstream os; std::ostringstream ref; os << *p; ref << v; - EXPECT_EQ(os.str(), ref.str()); + EXPECT_TRUE(os.str() == ref.str()); } } @@ -275,7 +275,7 @@ TEST(notnull_tests, TestNotNullCasting) not_null p{&derived}; not_null q(&base); q = p; // allowed with heterogeneous copy ctor - EXPECT_EQ(q, p); + EXPECT_TRUE(q == p); #ifdef CONFIRM_COMPILATION_ERRORS q = u; // no viable conversion possible between MyBase* and Unrelated* @@ -285,7 +285,7 @@ TEST(notnull_tests, TestNotNullCasting) not_null s = reinterpret_cast(p); #endif not_null t(reinterpret_cast(p.get())); - EXPECT_EQ(reinterpret_cast(p.get()), reinterpret_cast(t.get())); + EXPECT_TRUE(reinterpret_cast(p.get()) == reinterpret_cast(t.get())); } TEST(notnull_tests, TestNotNullAssignment) @@ -307,23 +307,23 @@ TEST(notnull_tests, TestNotNullRawPointerComparison) using NotNull1 = not_null; using NotNull2 = not_null; - EXPECT_EQ((NotNull1(p1) == NotNull1(p1)), true); - EXPECT_EQ((NotNull1(p1) == NotNull2(p2)), false); + EXPECT_TRUE((NotNull1(p1) == NotNull1(p1)) == true); + EXPECT_TRUE((NotNull1(p1) == NotNull2(p2)) == false); - EXPECT_EQ((NotNull1(p1) != NotNull1(p1)), false); - EXPECT_EQ((NotNull1(p1) != NotNull2(p2)), true); + EXPECT_TRUE((NotNull1(p1) != NotNull1(p1)) == false); + EXPECT_TRUE((NotNull1(p1) != NotNull2(p2)) == true); - EXPECT_EQ((NotNull1(p1) < NotNull1(p1)), false); - EXPECT_EQ((NotNull1(p1) < NotNull2(p2)), (p1 < p2)); - EXPECT_EQ((NotNull2(p2) < NotNull1(p1)), (p2 < p1)); + EXPECT_TRUE((NotNull1(p1) < NotNull1(p1)) == false); + EXPECT_TRUE((NotNull1(p1) < NotNull2(p2)) == (p1 < p2)); + EXPECT_TRUE((NotNull2(p2) < NotNull1(p1)) == (p2 < p1)); - EXPECT_EQ((NotNull1(p1) > NotNull1(p1)), false); - EXPECT_EQ((NotNull1(p1) > NotNull2(p2)), (p1 > p2)); - EXPECT_EQ((NotNull2(p2) > NotNull1(p1)), (p2 > p1)); + EXPECT_TRUE((NotNull1(p1) > NotNull1(p1)) == false); + EXPECT_TRUE((NotNull1(p1) > NotNull2(p2)) == (p1 > p2)); + EXPECT_TRUE((NotNull2(p2) > NotNull1(p1)) == (p2 > p1)); - EXPECT_EQ((NotNull1(p1) <= NotNull1(p1)), true); - EXPECT_EQ((NotNull1(p1) <= NotNull2(p2)), (p1 <= p2)); - EXPECT_EQ((NotNull2(p2) <= NotNull1(p1)), (p2 <= p1)); + EXPECT_TRUE((NotNull1(p1) <= NotNull1(p1)) == true); + EXPECT_TRUE((NotNull1(p1) <= NotNull2(p2)) == (p1 <= p2)); + EXPECT_TRUE((NotNull2(p2) <= NotNull1(p1)) == (p2 <= p1)); } TEST(notnull_tests, TestNotNullDereferenceOperator) @@ -332,8 +332,8 @@ TEST(notnull_tests, TestNotNullDereferenceOperator) auto sp1 = std::make_shared(); using NotNullSp1 = not_null; - EXPECT_EQ(typeid(*sp1), typeid(*NotNullSp1(sp1))); - EXPECT_EQ(std::addressof(*NotNullSp1(sp1)), std::addressof(*sp1)); + EXPECT_TRUE(typeid(*sp1) == typeid(*NotNullSp1(sp1))); + EXPECT_TRUE(std::addressof(*NotNullSp1(sp1)) == std::addressof(*sp1)); } { @@ -341,18 +341,18 @@ TEST(notnull_tests, TestNotNullDereferenceOperator) CustomPtr p1(&ints[0]); using NotNull1 = not_null; - EXPECT_EQ(typeid(*NotNull1(p1)), typeid(*p1)); - EXPECT_EQ(*NotNull1(p1), 42); + EXPECT_TRUE(typeid(*NotNull1(p1)) == typeid(*p1)); + EXPECT_TRUE(*NotNull1(p1) == 42); *NotNull1(p1) = 43; - EXPECT_EQ(ints[0], 43); + EXPECT_TRUE(ints[0] == 43); } { int v = 42; gsl::not_null p(&v); - EXPECT_EQ(typeid(*p), typeid(*(&v))); + EXPECT_TRUE(typeid(*p) == typeid(*(&v))); *p = 43; - EXPECT_EQ(v, 43); + EXPECT_TRUE(v == 43); } } @@ -364,27 +364,27 @@ TEST(notnull_tests, TestNotNullSharedPtrComparison) using NotNullSp1 = not_null; using NotNullSp2 = not_null; - EXPECT_EQ((NotNullSp1(sp1) == NotNullSp1(sp1)), true); - EXPECT_EQ((NotNullSp1(sp1) == NotNullSp2(sp2)), false); + EXPECT_TRUE((NotNullSp1(sp1) == NotNullSp1(sp1)) == true); + EXPECT_TRUE((NotNullSp1(sp1) == NotNullSp2(sp2)) == false); - EXPECT_EQ((NotNullSp1(sp1) != NotNullSp1(sp1)), false); - EXPECT_EQ((NotNullSp1(sp1) != NotNullSp2(sp2)), true); + EXPECT_TRUE((NotNullSp1(sp1) != NotNullSp1(sp1)) == false); + EXPECT_TRUE((NotNullSp1(sp1) != NotNullSp2(sp2)) == true); - EXPECT_EQ((NotNullSp1(sp1) < NotNullSp1(sp1)), false); - EXPECT_EQ((NotNullSp1(sp1) < NotNullSp2(sp2)), (sp1 < sp2)); - EXPECT_EQ((NotNullSp2(sp2) < NotNullSp1(sp1)), (sp2 < sp1)); + EXPECT_TRUE((NotNullSp1(sp1) < NotNullSp1(sp1)) == false); + EXPECT_TRUE((NotNullSp1(sp1) < NotNullSp2(sp2)) == (sp1 < sp2)); + EXPECT_TRUE((NotNullSp2(sp2) < NotNullSp1(sp1)) == (sp2 < sp1)); - EXPECT_EQ((NotNullSp1(sp1) > NotNullSp1(sp1)), false); - EXPECT_EQ((NotNullSp1(sp1) > NotNullSp2(sp2)), (sp1 > sp2)); - EXPECT_EQ((NotNullSp2(sp2) > NotNullSp1(sp1)), (sp2 > sp1)); + EXPECT_TRUE((NotNullSp1(sp1) > NotNullSp1(sp1)) == false); + EXPECT_TRUE((NotNullSp1(sp1) > NotNullSp2(sp2)) == (sp1 > sp2)); + EXPECT_TRUE((NotNullSp2(sp2) > NotNullSp1(sp1)) == (sp2 > sp1)); - EXPECT_EQ((NotNullSp1(sp1) <= NotNullSp1(sp1)), true); - EXPECT_EQ((NotNullSp1(sp1) <= NotNullSp2(sp2)), (sp1 <= sp2)); - EXPECT_EQ((NotNullSp2(sp2) <= NotNullSp1(sp1)), (sp2 <= sp1)); + EXPECT_TRUE((NotNullSp1(sp1) <= NotNullSp1(sp1)) == true); + EXPECT_TRUE((NotNullSp1(sp1) <= NotNullSp2(sp2)) == (sp1 <= sp2)); + EXPECT_TRUE((NotNullSp2(sp2) <= NotNullSp1(sp1)) == (sp2 <= sp1)); - EXPECT_EQ((NotNullSp1(sp1) >= NotNullSp1(sp1)), true); - EXPECT_EQ((NotNullSp1(sp1) >= NotNullSp2(sp2)), (sp1 >= sp2)); - EXPECT_EQ((NotNullSp2(sp2) >= NotNullSp1(sp1)), (sp2 >= sp1)); + EXPECT_TRUE((NotNullSp1(sp1) >= NotNullSp1(sp1)) == true); + EXPECT_TRUE((NotNullSp1(sp1) >= NotNullSp2(sp2)) == (sp1 >= sp2)); + EXPECT_TRUE((NotNullSp2(sp2) >= NotNullSp1(sp1)) == (sp2 >= sp1)); } TEST(notnull_tests, TestNotNullCustomPtrComparison) @@ -396,27 +396,27 @@ TEST(notnull_tests, TestNotNullCustomPtrComparison) using NotNull1 = not_null; using NotNull2 = not_null; - EXPECT_EQ((NotNull1(p1) == NotNull1(p1)), "true"); - EXPECT_EQ((NotNull1(p1) == NotNull2(p2)), "false"); + EXPECT_TRUE((NotNull1(p1) == NotNull1(p1)) == "true"); + EXPECT_TRUE((NotNull1(p1) == NotNull2(p2)) == "false"); - EXPECT_EQ((NotNull1(p1) != NotNull1(p1)), "false"); - EXPECT_EQ((NotNull1(p1) != NotNull2(p2)), "true"); + EXPECT_TRUE((NotNull1(p1) != NotNull1(p1)) == "false"); + EXPECT_TRUE((NotNull1(p1) != NotNull2(p2)) == "true"); - EXPECT_EQ((NotNull1(p1) < NotNull1(p1)), "false"); - EXPECT_EQ((NotNull1(p1) < NotNull2(p2)), (p1 < p2)); - EXPECT_EQ((NotNull2(p2) < NotNull1(p1)), (p2 < p1)); + EXPECT_TRUE((NotNull1(p1) < NotNull1(p1)) == "false"); + EXPECT_TRUE((NotNull1(p1) < NotNull2(p2)) == (p1 < p2)); + EXPECT_TRUE((NotNull2(p2) < NotNull1(p1)) == (p2 < p1)); - EXPECT_EQ((NotNull1(p1) > NotNull1(p1)), "false"); - EXPECT_EQ((NotNull1(p1) > NotNull2(p2)), (p1 > p2)); - EXPECT_EQ((NotNull2(p2) > NotNull1(p1)), (p2 > p1)); + EXPECT_TRUE((NotNull1(p1) > NotNull1(p1)) == "false"); + EXPECT_TRUE((NotNull1(p1) > NotNull2(p2)) == (p1 > p2)); + EXPECT_TRUE((NotNull2(p2) > NotNull1(p1)) == (p2 > p1)); - EXPECT_EQ((NotNull1(p1) <= NotNull1(p1)), "true"); - EXPECT_EQ((NotNull1(p1) <= NotNull2(p2)), (p1 <= p2)); - EXPECT_EQ((NotNull2(p2) <= NotNull1(p1)), (p2 <= p1)); + EXPECT_TRUE((NotNull1(p1) <= NotNull1(p1)) == "true"); + EXPECT_TRUE((NotNull1(p1) <= NotNull2(p2)) == (p1 <= p2)); + EXPECT_TRUE((NotNull2(p2) <= NotNull1(p1)) == (p2 <= p1)); - EXPECT_EQ((NotNull1(p1) >= NotNull1(p1)), "true"); - EXPECT_EQ((NotNull1(p1) >= NotNull2(p2)), (p1 >= p2)); - EXPECT_EQ((NotNull2(p2) >= NotNull1(p1)), (p2 >= p1)); + EXPECT_TRUE((NotNull1(p1) >= NotNull1(p1)) == "true"); + EXPECT_TRUE((NotNull1(p1) >= NotNull2(p2)) == (p1 >= p2)); + EXPECT_TRUE((NotNull2(p2) >= NotNull1(p1)) == (p2 >= p1)); } #if defined(__cplusplus) && (__cplusplus >= 201703L) @@ -430,7 +430,7 @@ TEST(notnull_tests, TestNotNullConstructorTypeDeduction) helper(not_null{&i}); helper_const(not_null{&i}); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { @@ -441,7 +441,7 @@ TEST(notnull_tests, TestNotNullConstructorTypeDeduction) helper(not_null{p}); helper_const(not_null{p}); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { @@ -486,7 +486,7 @@ TEST(notnull_tests, TestMakeNotNull) helper(make_not_null(&i)); helper_const(make_not_null(&i)); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { @@ -497,14 +497,14 @@ TEST(notnull_tests, TestMakeNotNull) helper(make_not_null(p)); helper_const(make_not_null(p)); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { const auto workaround_macro = []() { int* p1 = nullptr; const auto x = make_not_null(p1); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); }; EXPECT_DEATH(workaround_macro(), ".*"); } @@ -513,7 +513,7 @@ TEST(notnull_tests, TestMakeNotNull) const auto workaround_macro = []() { const int* p1 = nullptr; const auto x = make_not_null(p1); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); }; EXPECT_DEATH(workaround_macro(), ".*"); } diff --git a/tests/owner_tests.cpp b/tests/owner_tests.cpp index 2e7a1d4..8dafbde 100644 --- a/tests/owner_tests.cpp +++ b/tests/owner_tests.cpp @@ -42,9 +42,9 @@ void f(int* i) { *i += 1; } TEST(owner_tests, basic_test) { owner p = new int(120); - EXPECT_EQ(*p, 120); + EXPECT_TRUE(*p == 120); f(p); - EXPECT_EQ(*p, 121); + EXPECT_TRUE(*p == 121); delete p; } diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index 2f39d2b..cb21e5c 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -77,55 +77,55 @@ struct AddressOverloaded TEST(span_test, constructors) { span s; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); span cs; - EXPECT_EQ(cs.size(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.size() == 0); + EXPECT_TRUE(cs.data() == nullptr); } TEST(span_test, constructors_with_extent) { span s; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); span cs; - EXPECT_EQ(cs.size(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.size() == 0); + EXPECT_TRUE(cs.data() == nullptr); } TEST(span_test, constructors_with_bracket_init) { span s{}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); span cs{}; - EXPECT_EQ(cs.size(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.size() == 0); + EXPECT_TRUE(cs.data() == nullptr); } TEST(span_test, size_optimization) { span s; - EXPECT_EQ(sizeof(s), sizeof(int*) + sizeof(ptrdiff_t)); + EXPECT_TRUE(sizeof(s) == sizeof(int*) + sizeof(ptrdiff_t)); span se; - EXPECT_EQ(sizeof(se), sizeof(int*)); + EXPECT_TRUE(sizeof(se) == sizeof(int*)); } TEST(span_test, from_nullptr_size_constructor) { { span s{nullptr, narrow_cast::index_type>(0)}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); span cs{nullptr, narrow_cast::index_type>(0)}; - EXPECT_EQ(cs.size(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.size() == 0); + EXPECT_TRUE(cs.data() == nullptr); } { auto workaround_macro = []() { @@ -149,12 +149,12 @@ TEST(span_test, from_nullptr_size_constructor) } { span s{nullptr, narrow_cast::index_type>(0)}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); span cs{nullptr, narrow_cast::index_type>(0)}; - EXPECT_EQ(cs.size(), 0); - EXPECT_EQ(cs.data(), nullptr); + EXPECT_TRUE(cs.size() == 0); + EXPECT_TRUE(cs.data() == nullptr); } } @@ -167,27 +167,27 @@ TEST(span_test, from_pointer_length_constructor) { { span s = {&arr[0], i}; - EXPECT_EQ(s.size(), i); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s.empty(), i == 0); + EXPECT_TRUE(s.size() == i); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s.empty() == (i == 0)); for (int j = 0; j < i; ++j) { - EXPECT_EQ(arr[j], s[j]); - EXPECT_EQ(arr[j], s.at(j)); - EXPECT_EQ(arr[j], s(j)); + EXPECT_TRUE(arr[j] == s[j]); + EXPECT_TRUE(arr[j] == s.at(j)); + EXPECT_TRUE(arr[j] == s(j)); } } { span s = {&arr[i], 4 - narrow_cast(i)}; - EXPECT_EQ(s.size(), 4 - i); - EXPECT_EQ(s.data(), &arr[i]); - EXPECT_EQ(s.empty(), (4 - i) == 0); + EXPECT_TRUE(s.size() == 4 - i); + EXPECT_TRUE(s.data() == &arr[i]); + EXPECT_TRUE(s.empty() == ((4 - i) == 0)); for (int j = 0; j < 4 - i; ++j) { - EXPECT_EQ(arr[j + i], s[j]); - EXPECT_EQ(arr[j + i], s.at(j)); - EXPECT_EQ(arr[j + i], s(j)); + EXPECT_TRUE(arr[j + i] == s[j]); + EXPECT_TRUE(arr[j + i] == s.at(j)); + EXPECT_TRUE(arr[j + i] == s(j)); } } } @@ -195,17 +195,17 @@ TEST(span_test, from_pointer_length_constructor) { span s{&arr[0], 2}; - EXPECT_EQ(s.size(), 2); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[1], 2); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[1] == 2); } { int* p = nullptr; span s{p, narrow_cast::index_type>(0)}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); } { @@ -216,17 +216,17 @@ TEST(span_test, from_pointer_length_constructor) { auto s = make_span(&arr[0], 2); - EXPECT_EQ(s.size(), 2); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[1], 2); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[1] == 2); } { int* p = nullptr; auto s = make_span(p, narrow_cast::index_type>(0)); - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); } { @@ -242,29 +242,29 @@ TEST(span_test, from_pointer_pointer_construction) { span s{&arr[0], &arr[2]}; - EXPECT_EQ(s.size(), 2); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[1], 2); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[1] == 2); } { span s{&arr[0], &arr[2]}; - EXPECT_EQ(s.size(), 2); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[1], 2); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[1] == 2); } { span s{&arr[0], &arr[0]}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == &arr[0]); } { span s{&arr[0], &arr[0]}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == &arr[0]); } // this will fail the std::distance() precondition, which asserts on MSVC debug builds @@ -283,15 +283,15 @@ TEST(span_test, from_pointer_pointer_construction) { int* p = nullptr; span s{p, p}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); } { int* p = nullptr; span s{p, p}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); } // this will fail the std::distance() precondition, which asserts on MSVC debug builds @@ -303,23 +303,23 @@ TEST(span_test, from_pointer_pointer_construction) { auto s = make_span(&arr[0], &arr[2]); - EXPECT_EQ(s.size(), 2); - EXPECT_EQ(s.data(), &arr[0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[1], 2); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == &arr[0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[1] == 2); } { auto s = make_span(&arr[0], &arr[0]); - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == &arr[0]); } { int* p = nullptr; auto s = make_span(p, p); - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), nullptr); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == nullptr); } } @@ -329,14 +329,14 @@ TEST(span_test, from_array_constructor) { const span s{arr}; - EXPECT_EQ(s.size(), 5); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.size() == 5); + EXPECT_TRUE(s.data() == &arr[0]); } { const span s{arr}; - EXPECT_EQ(s.size(), 5); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.size() == 5); + EXPECT_TRUE(s.data() == &arr[0]); } int arr2d[2][3] = {1, 2, 3, 4, 5, 6}; @@ -348,22 +348,22 @@ TEST(span_test, from_array_constructor) { span s{arr}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), &arr[0]); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == &arr[0]); } { span s{arr2d}; - EXPECT_EQ(s.size(), 6); - EXPECT_EQ(s.data(), &arr2d[0][0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[5], 6); + EXPECT_TRUE(s.size() == 6); + EXPECT_TRUE(s.data() == &arr2d[0][0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[5] == 6); } { span s{arr2d}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), &arr2d[0][0]); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == &arr2d[0][0]); } { @@ -372,8 +372,8 @@ TEST(span_test, from_array_constructor) #endif { const span s{std::addressof(arr2d[0]), 1}; - EXPECT_EQ(s.size(), 1); - EXPECT_EQ(s.data(), std::addressof(arr2d[0])); + EXPECT_TRUE(s.size() == 1); + EXPECT_TRUE(s.data() == std::addressof(arr2d[0])); } int arr3d[2][3][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; @@ -381,16 +381,16 @@ TEST(span_test, from_array_constructor) #ifdef CONFIRM_COMPILATION_ERRORS { span s{arr3d}; - EXPECT_EQ(s.size(), 12); - EXPECT_EQ(s.data(), &arr3d[0][0][0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[11], 12); + EXPECT_TRUE(s.size() == 12); + EXPECT_TRUE(s.data() == &arr3d[0][0][0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[11] == 12); } { span s{arr3d}; - EXPECT_EQ(s.size(), 0); - EXPECT_EQ(s.data(), &arr3d[0][0][0]); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == &arr3d[0][0][0]); } { @@ -399,41 +399,41 @@ TEST(span_test, from_array_constructor) { span s{arr3d}; - EXPECT_EQ(s.size(), 12); - EXPECT_EQ(s.data(), &arr3d[0][0][0]); - EXPECT_EQ(s[0], 1); - EXPECT_EQ(s[5], 6); + EXPECT_TRUE(s.size() == 12); + EXPECT_TRUE(s.data() == &arr3d[0][0][0]); + EXPECT_TRUE(s[0] == 1); + EXPECT_TRUE(s[5] == 6); } #endif { const span s{std::addressof(arr3d[0]), 1}; - EXPECT_EQ(s.size(), 1); + EXPECT_TRUE(s.size() == 1); } { const auto s = make_span(arr); - EXPECT_EQ(s.size(), 5); - EXPECT_EQ(s.data(),std::addressof(arr[0])); + EXPECT_TRUE(s.size() == 5); + EXPECT_TRUE(s.data() == std::addressof(arr[0])); } { const auto s = make_span(std::addressof(arr2d[0]), 1); - EXPECT_EQ(s.size(), 1); - EXPECT_EQ(s.data(), std::addressof(arr2d[0])); + EXPECT_TRUE(s.size() == 1); + EXPECT_TRUE(s.data() == std::addressof(arr2d[0])); } { const auto s = make_span(std::addressof(arr3d[0]), 1); - EXPECT_EQ(s.size(), 1); - EXPECT_EQ(s.data(), std::addressof(arr3d[0])); + EXPECT_TRUE(s.size() == 1); + EXPECT_TRUE(s.data() == std::addressof(arr3d[0])); } AddressOverloaded ao_arr[5] = {}; { const span s{ao_arr}; - EXPECT_EQ(s.size(), 5); - EXPECT_EQ(s.data(), std::addressof(ao_arr[0])); + EXPECT_TRUE(s.size() == 5); + EXPECT_TRUE(s.data() == std::addressof(ao_arr[0])); } } @@ -443,12 +443,14 @@ TEST(span_test, from_array_constructor) { span s(&arr[0][0][0], 10); - EXPECT_EQ(s.size(), 10); EXPECT_EQ(s.data(), &arr[0][0][0]); + EXPECT_TRUE(s.size() == 10); + EXPECT_TRUE(s.data() == &arr[0][0][0]); } { auto s = make_span(&arr[0][0][0], 10); - EXPECT_EQ(s.size(), 10); EXPECT_EQ(s.data(), &arr[0][0][0]); + EXPECT_TRUE(s.size() == 10); + EXPECT_TRUE(s.data() == &arr[0][0][0]); } delete[] arr; @@ -460,24 +462,28 @@ TEST(span_test, from_array_constructor) { span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); span cs{arr}; - EXPECT_EQ(cs.size(), narrow_cast(arr.size())); EXPECT_EQ(cs.data(), arr.data()); + EXPECT_TRUE(cs.size() == narrow_cast(arr.size())); + EXPECT_TRUE(cs.data() == arr.data()); } { span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); span cs{arr}; - EXPECT_EQ(cs.size(), narrow_cast(arr.size())); EXPECT_EQ(cs.data(), arr.data()); + EXPECT_TRUE(cs.size() == narrow_cast(arr.size())); + EXPECT_TRUE(cs.data() == arr.data()); } { std::array empty_arr{}; span s{empty_arr}; - EXPECT_EQ(s.size(), 0); + EXPECT_TRUE(s.size() == 0); EXPECT_TRUE(s.empty()); } @@ -485,25 +491,29 @@ TEST(span_test, from_array_constructor) { span fs{ao_arr}; - EXPECT_EQ(fs.size(), narrow_cast(ao_arr.size())); - EXPECT_EQ(ao_arr.data(), fs.data()); + EXPECT_TRUE(fs.size() == narrow_cast(ao_arr.size())); + EXPECT_TRUE(ao_arr.data() == fs.data()); } #ifdef CONFIRM_COMPILATION_ERRORS { span s{arr}; - EXPECT_EQ(s.size(), 2); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == arr.data()); span cs{arr}; - EXPECT_EQ(cs.size(), 2); EXPECT_EQ(cs.data(), arr.data()); + EXPECT_TRUE(cs.size() == 2); + EXPECT_TRUE(cs.data() == arr.data()); } { span s{arr}; - EXPECT_EQ(s.size(), 0); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == arr.data()); span cs{arr}; - EXPECT_EQ(cs.size(), 0); EXPECT_EQ(cs.data(), arr.data()); + EXPECT_TRUE(cs.size() == 0); + EXPECT_TRUE(cs.data() == arr.data()); } { @@ -527,7 +537,8 @@ TEST(span_test, from_array_constructor) { auto s = make_span(arr); - EXPECT_EQ(s.size(), narrow_cast(arr.size())); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); } // This test checks for the bug found in gcc 6.1, 6.2, 6.3, 6.4, 6.5 7.1, 7.2, 7.3 - issue #590 @@ -541,10 +552,10 @@ TEST(span_test, from_array_constructor) __GNUC_PATCHLEVEL__ == 0 && defined(__OPTIMIZE__) // Known to be broken in gcc 6.4 and 6.5 with optimizations // Issue in gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83116 - EXPECT_EQ(s1.size(), 4); - EXPECT_EQ(s2.size(), 0); + EXPECT_TRUE(s1.size() == 4); + EXPECT_TRUE(s2.size() == 0); #else - EXPECT_EQ(s1.size(), s2.size()); + EXPECT_TRUE(s1.size() == s2.size()); #endif } } @@ -555,31 +566,35 @@ TEST(span_test, from_array_constructor) { span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); } { span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); } const std::array ao_arr{}; { span s{ao_arr}; - EXPECT_EQ(s.size(), narrow_cast(ao_arr.size())); - EXPECT_EQ(s.data(), ao_arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(ao_arr.size())); + EXPECT_TRUE(s.data() == ao_arr.data()); } #ifdef CONFIRM_COMPILATION_ERRORS { span s{arr}; - EXPECT_EQ(s.size(), 2); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == arr.data()); } { span s{arr}; - EXPECT_EQ(s.size(), 0); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == arr.data()); } { @@ -596,7 +611,8 @@ TEST(span_test, from_array_constructor) { auto s = make_span(arr); - EXPECT_EQ(s.size(), narrow_cast(arr.size())); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); } } @@ -606,23 +622,27 @@ TEST(span_test, from_array_constructor) { span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); } { span s{arr}; - EXPECT_EQ(s.size(), narrow_cast(arr.size())); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); } #ifdef CONFIRM_COMPILATION_ERRORS { span s{arr}; - EXPECT_EQ(s.size(), 2); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == arr.data()); } { span s{arr}; - EXPECT_EQ(s.size(), 0); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == 0); + EXPECT_TRUE(s.data() == arr.data()); } { @@ -636,7 +656,8 @@ TEST(span_test, from_array_constructor) { auto s = make_span(arr); - EXPECT_EQ(s.size(), narrow_cast(arr.size())); EXPECT_EQ(s.data(), arr.data()); + EXPECT_TRUE(s.size() == narrow_cast(arr.size())); + EXPECT_TRUE(s.data() == arr.data()); } } @@ -647,10 +668,12 @@ TEST(span_test, from_array_constructor) { span s{v}; - EXPECT_EQ(s.size(), narrow_cast(v.size())); EXPECT_EQ(s.data(), v.data()); + EXPECT_TRUE(s.size() == narrow_cast(v.size())); + EXPECT_TRUE(s.data() == v.data()); span cs{v}; - EXPECT_EQ(cs.size(), narrow_cast(v.size())); EXPECT_EQ(cs.data(), v.data()); + EXPECT_TRUE(cs.size() == narrow_cast(v.size())); + EXPECT_TRUE(cs.data() == v.data()); } std::string str = "hello"; @@ -659,12 +682,12 @@ TEST(span_test, from_array_constructor) { #ifdef CONFIRM_COMPILATION_ERRORS span s{str}; - EXPECT_EQ(s.size(), narrow_cast(str.size())); - EXPECT_EQ(s.data(), str.data())); + EXPECT_TRUE(s.size() == narrow_cast(str.size())); + EXPECT_TRUE(s.data() == str.data())); #endif span cs{str}; - EXPECT_EQ(cs.size(), narrow_cast(str.size())); - EXPECT_EQ(cs.data(), str.data()); + EXPECT_TRUE(cs.size() == narrow_cast(str.size())); + EXPECT_TRUE(cs.data() == str.data()); } { @@ -672,8 +695,8 @@ TEST(span_test, from_array_constructor) span s{cstr}; #endif span cs{cstr}; - EXPECT_EQ(cs.size(), narrow_cast(cstr.size())); - EXPECT_EQ(cs.data(), cstr.data()); + EXPECT_TRUE(cs.size() == narrow_cast(cstr.size())); + EXPECT_TRUE(cs.data() == cstr.data()); } { @@ -727,11 +750,12 @@ TEST(span_test, from_array_constructor) { auto s = make_span(v); - EXPECT_EQ(s.size(), narrow_cast(v.size())); EXPECT_EQ(s.data(), v.data()); + EXPECT_TRUE(s.size() == narrow_cast(v.size())); + EXPECT_TRUE(s.data() == v.data()); auto cs = make_span(cv); - EXPECT_EQ(cs.size(), narrow_cast(cv.size())); - EXPECT_EQ(cs.data(), cv.data()); + EXPECT_TRUE(cs.size() == narrow_cast(cv.size())); + EXPECT_TRUE(cs.data() == cv.data()); } } @@ -777,17 +801,21 @@ TEST(span_test, from_array_constructor) int arr[] = {3, 4, 5}; span s2 = arr; - EXPECT_EQ(s2.size(), 3); EXPECT_EQ(s2.data(), &arr[0]); + EXPECT_TRUE(s2.size() == 3); + EXPECT_TRUE(s2.data() == &arr[0]); s2 = s1; EXPECT_TRUE(s2.empty()); auto get_temp_span = [&]() -> span { return {&arr[1], 2}; }; - auto use_span = [&](span s) { EXPECT_EQ(s.size(), 2); EXPECT_EQ(s.data(), &arr[1]); + auto use_span = [&](span s) { + EXPECT_TRUE(s.size() == 2); + EXPECT_TRUE(s.data() == &arr[1]); }; use_span(get_temp_span()); s1 = get_temp_span(); - EXPECT_EQ(s1.size(), 2); EXPECT_EQ(s1.data(), &arr[1]); + EXPECT_TRUE(s1.size() == 2); + EXPECT_TRUE(s1.data() == &arr[1]); } TEST(span_test, first) @@ -796,35 +824,35 @@ TEST(span_test, from_array_constructor) { span av = arr; - EXPECT_EQ(av.first<2>().size(), 2); - EXPECT_EQ(av.first(2).size(), 2); + EXPECT_TRUE(av.first<2>().size() == 2); + EXPECT_TRUE(av.first(2).size() == 2); } { span av = arr; - EXPECT_EQ(av.first<0>().size(), 0); - EXPECT_EQ(av.first(0).size(), 0); + EXPECT_TRUE(av.first<0>().size() == 0); + EXPECT_TRUE(av.first(0).size() == 0); } { span av = arr; - EXPECT_EQ(av.first<5>().size(), 5); - EXPECT_EQ(av.first(5).size(), 5); + EXPECT_TRUE(av.first<5>().size() == 5); + EXPECT_TRUE(av.first(5).size() == 5); } { span av = arr; #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(av.first<6>().size(), 6); - EXPECT_EQ(av.first<-1>().size(), -1); + EXPECT_TRUE(av.first<6>().size() == 6); + EXPECT_TRUE(av.first<-1>().size() == -1); #endif EXPECT_DEATH(av.first(6).size(), ".*"); } { span av; - EXPECT_EQ(av.first<0>().size(), 0); - EXPECT_EQ(av.first(0).size(), 0); + EXPECT_TRUE(av.first<0>().size() == 0); + EXPECT_TRUE(av.first(0).size() == 0); } } @@ -834,34 +862,34 @@ TEST(span_test, from_array_constructor) { span av = arr; - EXPECT_EQ(av.last<2>().size(), 2); - EXPECT_EQ(av.last(2).size(), 2); + EXPECT_TRUE(av.last<2>().size() == 2); + EXPECT_TRUE(av.last(2).size() == 2); } { span av = arr; - EXPECT_EQ(av.last<0>().size(), 0); - EXPECT_EQ(av.last(0).size(), 0); + EXPECT_TRUE(av.last<0>().size() == 0); + EXPECT_TRUE(av.last(0).size() == 0); } { span av = arr; - EXPECT_EQ(av.last<5>().size(), 5); - EXPECT_EQ(av.last(5).size(), 5); + EXPECT_TRUE(av.last<5>().size() == 5); + EXPECT_TRUE(av.last(5).size() == 5); } { span av = arr; #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(av.last<6>().size(), 6); + EXPECT_TRUE(av.last<6>().size() == 6); #endif EXPECT_DEATH(av.last(6).size(), ".*"); } { span av; - EXPECT_EQ(av.last<0>().size(), 0); - EXPECT_EQ(av.last(0).size(), 0); + EXPECT_TRUE(av.last<0>().size() == 0); + EXPECT_TRUE(av.last(0).size() == 0); } } @@ -871,24 +899,24 @@ TEST(span_test, from_array_constructor) { span av = arr; - EXPECT_EQ((av.subspan<2, 2>().size()), 2); - EXPECT_EQ(decltype(av.subspan<2, 2>())::extent, 2); - EXPECT_EQ(av.subspan(2, 2).size(), 2); - EXPECT_EQ(av.subspan(2, 3).size(), 3); + EXPECT_TRUE((av.subspan<2, 2>().size()) == 2); + EXPECT_TRUE(decltype(av.subspan<2, 2>())::extent == 2); + EXPECT_TRUE(av.subspan(2, 2).size() == 2); + EXPECT_TRUE(av.subspan(2, 3).size() == 3); } { span av = arr; - EXPECT_EQ((av.subspan<0, 0>().size()), 0); - EXPECT_EQ(decltype(av.subspan<0, 0>())::extent, 0); - EXPECT_EQ(av.subspan(0, 0).size(), 0); + 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); } { span av = arr; - EXPECT_EQ((av.subspan<0, 5>().size()), 5); - EXPECT_EQ(decltype(av.subspan<0, 5>())::extent, 5); - EXPECT_EQ(av.subspan(0, 5).size(), 5); + EXPECT_TRUE((av.subspan<0, 5>().size()) == 5); + EXPECT_TRUE(decltype(av.subspan<0, 5>())::extent == 5); + EXPECT_TRUE(av.subspan(0, 5).size() == 5); EXPECT_DEATH(av.subspan(0, 6).size(), ".*"); EXPECT_DEATH(av.subspan(1, 5).size(), ".*"); @@ -896,53 +924,53 @@ TEST(span_test, from_array_constructor) { span av = arr; - EXPECT_EQ((av.subspan<4, 0>().size()), 0); - EXPECT_EQ(decltype(av.subspan<4, 0>())::extent, 0); - EXPECT_EQ(av.subspan(4, 0).size(), 0); - EXPECT_EQ(av.subspan(5, 0).size(), 0); + EXPECT_TRUE((av.subspan<4, 0>().size()) == 0); + 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(), ".*"); } { span av = arr; - EXPECT_EQ(av.subspan<1>().size(), 4); - EXPECT_EQ(decltype(av.subspan<1>())::extent, 4); + EXPECT_TRUE(av.subspan<1>().size() == 4); + EXPECT_TRUE(decltype(av.subspan<1>())::extent == 4); } { span av; - EXPECT_EQ((av.subspan<0, 0>().size()), 0); - EXPECT_EQ(decltype(av.subspan<0, 0>())::extent, 0); - EXPECT_EQ(av.subspan(0, 0).size(), 0); + 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()), ".*"); } { span av; - EXPECT_EQ(av.subspan(0).size(), 0); + EXPECT_TRUE(av.subspan(0).size() == 0); EXPECT_DEATH(av.subspan(1).size(), ".*"); } { span av = arr; - EXPECT_EQ(av.subspan(0).size(), 5); - EXPECT_EQ(av.subspan(1).size(), 4); - EXPECT_EQ(av.subspan(4).size(), 1); - EXPECT_EQ(av.subspan(5).size(), 0); + EXPECT_TRUE(av.subspan(0).size() == 5); + 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(), ".*"); const auto av2 = av.subspan(1); - for (int i = 0; i < 4; ++i) EXPECT_EQ(av2[i], i + 2); + for (int i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); } { span av = arr; - EXPECT_EQ(av.subspan(0).size(), 5); - EXPECT_EQ(av.subspan(1).size(), 4); - EXPECT_EQ(av.subspan(4).size(), 1); - EXPECT_EQ(av.subspan(5).size(), 0); + EXPECT_TRUE(av.subspan(0).size() == 5); + 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(), ".*"); const auto av2 = av.subspan(1); - for (int i = 0; i < 4; ++i) EXPECT_EQ(av2[i], i + 2); + for (int i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); } } @@ -952,15 +980,15 @@ TEST(span_test, from_array_constructor) { span s = arr; - EXPECT_EQ(s.at(0), 1); + EXPECT_TRUE(s.at(0) == 1); EXPECT_DEATH(s.at(5), ".*"); } { int arr2d[2] = {1, 6}; span s = arr2d; - EXPECT_EQ(s.at(0), 1); - EXPECT_EQ(s.at(1), 6); + EXPECT_TRUE(s.at(0) == 1); + EXPECT_TRUE(s.at(1) == 6); EXPECT_DEATH(s.at(2), ".*"); } } @@ -971,15 +999,15 @@ TEST(span_test, from_array_constructor) { span s = arr; - EXPECT_EQ(s(0), 1); + EXPECT_TRUE(s(0) == 1); EXPECT_DEATH(s(5), ".*"); } { int arr2d[2] = {1, 6}; span s = arr2d; - EXPECT_EQ(s(0), 1); - EXPECT_EQ(s(1), 6); + EXPECT_TRUE(s(0) == 1); + EXPECT_TRUE(s(1) == 6); EXPECT_DEATH(s(2), ".*"); } } @@ -988,21 +1016,21 @@ TEST(span_test, from_array_constructor) { span::iterator it1; span::iterator it2; - EXPECT_EQ(it1, it2); + EXPECT_TRUE(it1 == it2); } TEST(span_test, const_iterator_default_init) { span::const_iterator it1; span::const_iterator it2; - EXPECT_EQ(it1, it2); + EXPECT_TRUE(it1 == it2); } TEST(span_test, iterator_conversions) { span::iterator badIt; span::const_iterator badConstIt; - EXPECT_EQ(badIt, badConstIt); + EXPECT_TRUE(badIt == badConstIt); int a[] = {1, 2, 3, 4}; span s = a; @@ -1010,14 +1038,14 @@ TEST(span_test, from_array_constructor) auto it = s.begin(); auto cit = s.cbegin(); - EXPECT_EQ(it, cit); - EXPECT_EQ(cit, it); + EXPECT_TRUE(it == cit); + EXPECT_TRUE(cit == it); span::const_iterator cit2 = it; - EXPECT_EQ(cit2, cit); + EXPECT_TRUE(cit2 == cit); span::const_iterator cit3 = it + 4; - EXPECT_EQ(cit3, s.cend()); + EXPECT_TRUE(cit3 == s.cend()); } TEST(span_test, iterator_comparisons) @@ -1029,41 +1057,41 @@ TEST(span_test, from_array_constructor) auto it2 = it + 1; span::const_iterator cit = s.cbegin(); - EXPECT_EQ(it, cit); - EXPECT_EQ(cit, it); - EXPECT_EQ(it, it); - EXPECT_EQ(cit, cit); - EXPECT_EQ(cit, s.begin()); - EXPECT_EQ(s.begin(), cit); - EXPECT_EQ(s.cbegin(), cit); - EXPECT_EQ(it, s.begin()); - EXPECT_EQ(s.begin(), it); + EXPECT_TRUE(it == cit); + EXPECT_TRUE(cit == it); + EXPECT_TRUE(it == it); + EXPECT_TRUE(cit == cit); + EXPECT_TRUE(cit == s.begin()); + EXPECT_TRUE(s.begin() == cit); + EXPECT_TRUE(s.cbegin() == cit); + EXPECT_TRUE(it == s.begin()); + EXPECT_TRUE(s.begin() == it); - EXPECT_NE(it, it2); - EXPECT_NE(it2, it); - EXPECT_NE(it, s.end()); - EXPECT_NE(it2, s.end()); - EXPECT_NE(s.end(), it); - EXPECT_NE(it2, cit); - EXPECT_NE(cit, it2); + EXPECT_TRUE(it != it2); + EXPECT_TRUE(it2 != it); + EXPECT_TRUE(it != s.end()); + EXPECT_TRUE(it2 != s.end()); + EXPECT_TRUE(s.end() != it); + EXPECT_TRUE(it2 != cit); + EXPECT_TRUE(cit != it2); - EXPECT_LT(it, it2); - EXPECT_LE(it, it2); - EXPECT_LE(it2, s.end()); - EXPECT_LT(it, s.end()); - EXPECT_LE(it, cit); - EXPECT_LE(cit, it); - EXPECT_LT(cit, it2); - EXPECT_LE(cit, it2); - EXPECT_LT(cit, s.end()); - EXPECT_LE(cit, s.end()); + EXPECT_TRUE(it < it2); + EXPECT_TRUE(it <= it2); + EXPECT_TRUE(it2 <= s.end()); + EXPECT_TRUE(it < s.end()); + EXPECT_TRUE(it <= cit); + EXPECT_TRUE(cit <= it); + EXPECT_TRUE(cit < it2); + EXPECT_TRUE(cit <= it2); + EXPECT_TRUE(cit < s.end()); + EXPECT_TRUE(cit <= s.end()); - EXPECT_GT(it2, it); - EXPECT_GE(it2, it); - EXPECT_GT(s.end(), it2); - EXPECT_GE(s.end(), it2); - EXPECT_GT(it2, cit); - EXPECT_GE(it2, cit); + EXPECT_TRUE(it2 > it); + EXPECT_TRUE(it2 >= it); + EXPECT_TRUE(s.end() > it2); + EXPECT_TRUE(s.end() >= it2); + EXPECT_TRUE(it2 > cit); + EXPECT_TRUE(it2 >= cit); } } @@ -1075,11 +1103,11 @@ TEST(span_test, from_array_constructor) span::iterator it = s.begin(); span::iterator it2 = std::begin(s); - EXPECT_EQ(it, it2); + EXPECT_TRUE(it == it2); it = s.end(); it2 = std::end(s); - EXPECT_EQ(it, it2); + EXPECT_TRUE(it == it2); } { @@ -1088,36 +1116,36 @@ TEST(span_test, from_array_constructor) auto it = s.begin(); auto first = it; - EXPECT_EQ(it, first); - EXPECT_EQ(*it, 1); + EXPECT_TRUE(it == first); + EXPECT_TRUE(*it == 1); auto beyond = s.end(); - EXPECT_NE(it, beyond); + EXPECT_TRUE(it != beyond); EXPECT_DEATH(*beyond, ".*"); - EXPECT_EQ(beyond - first, 4); - EXPECT_EQ(first - first, 0); - EXPECT_EQ(beyond - beyond, 0); + EXPECT_TRUE(beyond - first == 4); + EXPECT_TRUE(first - first == 0); + EXPECT_TRUE(beyond - beyond == 0); ++it; - EXPECT_EQ(it - first, 1); - EXPECT_EQ(*it, 2); + EXPECT_TRUE(it - first == 1); + EXPECT_TRUE(*it == 2); *it = 22; - EXPECT_EQ(*it, 22); - EXPECT_EQ(beyond - it, 3); + EXPECT_TRUE(*it == 22); + EXPECT_TRUE(beyond - it == 3); it = first; - EXPECT_EQ(it, first); + EXPECT_TRUE(it == first); while (it != s.end()) { *it = 5; ++it; } - EXPECT_EQ(it, beyond); - EXPECT_EQ(it - beyond, 0); + EXPECT_TRUE(it == beyond); + EXPECT_TRUE(it - beyond == 0); - for (const auto& n : s) { EXPECT_EQ(n, 5); } + for (const auto& n : s) { EXPECT_TRUE(n == 5); } } } @@ -1129,11 +1157,11 @@ TEST(span_test, from_array_constructor) span::const_iterator cit = s.cbegin(); span::const_iterator cit2 = std::cbegin(s); - EXPECT_EQ(cit, cit2); + EXPECT_TRUE(cit == cit2); cit = s.cend(); cit2 = std::cend(s); - EXPECT_EQ(cit, cit2); + EXPECT_TRUE(cit == cit2); } { @@ -1142,35 +1170,35 @@ TEST(span_test, from_array_constructor) auto it = s.cbegin(); auto first = it; - EXPECT_EQ(it, first); - EXPECT_EQ(*it, 1); + EXPECT_TRUE(it == first); + EXPECT_TRUE(*it == 1); auto beyond = s.cend(); - EXPECT_NE(it, beyond); + EXPECT_TRUE(it != beyond); EXPECT_DEATH(*beyond, ".*"); - EXPECT_EQ(beyond - first, 4); - EXPECT_EQ(first - first, 0); - EXPECT_EQ(beyond - beyond, 0); + EXPECT_TRUE(beyond - first == 4); + EXPECT_TRUE(first - first == 0); + EXPECT_TRUE(beyond - beyond == 0); ++it; - EXPECT_EQ(it - first, 1); - EXPECT_EQ(*it, 2); - EXPECT_EQ(beyond - it, 3); + EXPECT_TRUE(it - first == 1); + EXPECT_TRUE(*it == 2); + EXPECT_TRUE(beyond - it == 3); int last = 0; it = first; - EXPECT_EQ(it, first); + EXPECT_TRUE(it == first); while (it != s.cend()) { - EXPECT_EQ(*it, last + 1); + EXPECT_TRUE(*it == last + 1); last = *it; ++it; } - EXPECT_EQ(it, beyond); - EXPECT_EQ(it - beyond, 0); + EXPECT_TRUE(it == beyond); + EXPECT_TRUE(it - beyond == 0); } } @@ -1182,36 +1210,36 @@ TEST(span_test, from_array_constructor) auto it = s.rbegin(); auto first = it; - EXPECT_EQ(it, first); - EXPECT_EQ(*it, 4); + EXPECT_TRUE(it == first); + EXPECT_TRUE(*it == 4); auto beyond = s.rend(); - EXPECT_NE(it, beyond); + EXPECT_TRUE(it != beyond); //EXPECT_DEATH(*beyond, ".*"); - EXPECT_EQ(beyond - first, 4); - EXPECT_EQ(first - first, 0); - EXPECT_EQ(beyond - beyond, 0); + EXPECT_TRUE(beyond - first == 4); + EXPECT_TRUE(first - first == 0); + EXPECT_TRUE(beyond - beyond == 0); ++it; - EXPECT_EQ(it - first, 1); - EXPECT_EQ(*it, 3); + EXPECT_TRUE(it - first == 1); + EXPECT_TRUE(*it == 3); *it = 22; - EXPECT_EQ(*it, 22); - EXPECT_EQ(beyond - it, 3); + EXPECT_TRUE(*it == 22); + EXPECT_TRUE(beyond - it == 3); it = first; - EXPECT_EQ(it, first); + EXPECT_TRUE(it == first); while (it != s.rend()) { *it = 5; ++it; } - EXPECT_EQ(it, beyond); - EXPECT_EQ(it - beyond, 0); + EXPECT_TRUE(it == beyond); + EXPECT_TRUE(it - beyond == 0); - for (const auto& n : s) { EXPECT_EQ(n, 5); } + for (const auto& n : s) { EXPECT_TRUE(n == 5); } } } @@ -1223,35 +1251,35 @@ TEST(span_test, from_array_constructor) auto it = s.crbegin(); auto first = it; - EXPECT_EQ(it, first); - EXPECT_EQ(*it, 4); + EXPECT_TRUE(it == first); + EXPECT_TRUE(*it == 4); auto beyond = s.crend(); - EXPECT_NE(it, beyond); + EXPECT_TRUE(it != beyond); //EXPECT_DEATH(*beyond, ".*"); - EXPECT_EQ(beyond - first, 4); - EXPECT_EQ(first - first, 0); - EXPECT_EQ(beyond - beyond, 0); + EXPECT_TRUE(beyond - first == 4); + EXPECT_TRUE(first - first == 0); + EXPECT_TRUE(beyond - beyond == 0); ++it; - EXPECT_EQ(it - first, 1); - EXPECT_EQ(*it, 3); - EXPECT_EQ(beyond - it, 3); + EXPECT_TRUE(it - first == 1); + EXPECT_TRUE(*it == 3); + EXPECT_TRUE(beyond - it == 3); it = first; - EXPECT_EQ(it, first); + EXPECT_TRUE(it == first); int last = 5; while (it != s.crend()) { - EXPECT_EQ(*it, last - 1); + EXPECT_TRUE(*it == last - 1); last = *it; ++it; } - EXPECT_EQ(it, beyond); - EXPECT_EQ(it - beyond, 0); + EXPECT_TRUE(it == beyond); + EXPECT_TRUE(it - beyond == 0); } } @@ -1260,18 +1288,18 @@ TEST(span_test, from_array_constructor) { span s1; span s2; - EXPECT_EQ(s1, s2); + EXPECT_TRUE(s1 == s2); EXPECT_FALSE(s1 != s2); EXPECT_FALSE(s1 < s2); - EXPECT_LE(s1, s2); + EXPECT_TRUE(s1 <= s2); EXPECT_FALSE(s1 > s2); - EXPECT_GE(s1, s2); - EXPECT_EQ(s2, s1); + EXPECT_TRUE(s1 >= s2); + EXPECT_TRUE(s2 == s1); EXPECT_FALSE(s2 != s1); EXPECT_FALSE(s2 != s1); - EXPECT_LE(s2, s1); + EXPECT_TRUE(s2 <= s1); EXPECT_FALSE(s2 > s1); - EXPECT_GE(s2, s1); + EXPECT_TRUE(s2 >= s1); } { @@ -1279,18 +1307,18 @@ TEST(span_test, from_array_constructor) span s1 = arr; span s2 = arr; - EXPECT_EQ(s1, s2); + EXPECT_TRUE(s1 == s2); EXPECT_FALSE(s1 != s2); EXPECT_FALSE(s1 < s2); - EXPECT_LE(s1, s2); + EXPECT_TRUE(s1 <= s2); EXPECT_FALSE(s1 > s2); - EXPECT_GE(s1, s2); - EXPECT_EQ(s2, s1); + EXPECT_TRUE(s1 >= s2); + EXPECT_TRUE(s2 == s1); EXPECT_FALSE(s2 != s1); EXPECT_FALSE(s2 < s1); - EXPECT_LE(s2, s1); + EXPECT_TRUE(s2 <= s1); EXPECT_FALSE(s2 > s1); - EXPECT_GE(s2, s1); + EXPECT_TRUE(s2 >= s1); } { @@ -1299,17 +1327,17 @@ TEST(span_test, from_array_constructor) span s1; span s2 = arr; - EXPECT_NE(s1, s2); - EXPECT_NE(s2, s1); + EXPECT_TRUE(s1 != s2); + EXPECT_TRUE(s2 != s1); EXPECT_FALSE(s1 == s2); EXPECT_FALSE(s2 == s1); - EXPECT_LT(s1, s2); + EXPECT_TRUE(s1 < s2); EXPECT_FALSE(s2 < s1); - EXPECT_LE(s1, s2); + EXPECT_TRUE(s1 <= s2); EXPECT_FALSE(s2 <= s1); - EXPECT_GT(s2, s1); + EXPECT_TRUE(s2 > s1); EXPECT_FALSE(s1 > s2); - EXPECT_GE(s2, s1); + EXPECT_TRUE(s2 >= s1); EXPECT_FALSE(s1 >= s2); } @@ -1319,18 +1347,18 @@ TEST(span_test, from_array_constructor) span s1 = arr1; span s2 = arr2; - EXPECT_EQ(s1, s2); + EXPECT_TRUE(s1 == s2); EXPECT_FALSE(s1 != s2); EXPECT_FALSE(s1 < s2); - EXPECT_LE(s1, s2); + EXPECT_TRUE(s1 <= s2); EXPECT_FALSE(s1 > s2); - EXPECT_GE(s1, s2); - EXPECT_EQ(s2, s1); + EXPECT_TRUE(s1 >= s2); + EXPECT_TRUE(s2 == s1); EXPECT_FALSE(s2 != s1); EXPECT_FALSE(s2 < s1); - EXPECT_LE(s2, s1); + EXPECT_TRUE(s2 <= s1); EXPECT_FALSE(s2 > s1); - EXPECT_GE(s2, s1); + EXPECT_TRUE(s2 >= s1); } { @@ -1339,17 +1367,17 @@ TEST(span_test, from_array_constructor) span s1 = {&arr[0], 2}; // shorter span s2 = arr; // longer - EXPECT_NE(s1, s2); - EXPECT_NE(s2, s1); + EXPECT_TRUE(s1 != s2); + EXPECT_TRUE(s2 != s1); EXPECT_FALSE(s1 == s2); EXPECT_FALSE(s2 == s1); - EXPECT_LT(s1, s2); + EXPECT_TRUE(s1 < s2); EXPECT_FALSE(s2 < s1); - EXPECT_LE(s1, s2); + EXPECT_TRUE(s1 <= s2); EXPECT_FALSE(s2 <= s1); - EXPECT_GT(s2, s1); + EXPECT_TRUE(s2 > s1); EXPECT_FALSE(s1 > s2); - EXPECT_GE(s2, s1); + EXPECT_TRUE(s2 >= s1); EXPECT_FALSE(s1 >= s2); } @@ -1360,17 +1388,17 @@ TEST(span_test, from_array_constructor) span s1 = arr1; span s2 = arr2; - EXPECT_NE(s1, s2); - EXPECT_NE(s2, s1); + EXPECT_TRUE(s1 != s2); + EXPECT_TRUE(s2 != s1); EXPECT_FALSE(s1 == s2); EXPECT_FALSE(s2 == s1); - EXPECT_LT(s1, s2); + EXPECT_TRUE(s1 < s2); EXPECT_FALSE(s2 < s1); - EXPECT_LE(s1, s2); + EXPECT_TRUE(s1 <= s2); EXPECT_FALSE(s2 <= s1); - EXPECT_GT(s2, s1); + EXPECT_TRUE(s2 > s1); EXPECT_FALSE(s1 > s2); - EXPECT_GE(s2, s1); + EXPECT_TRUE(s2 >= s1); EXPECT_FALSE(s1 >= s2); } } @@ -1381,27 +1409,27 @@ TEST(span_test, from_array_constructor) { const span s = a; - EXPECT_EQ(s.size(), 4); + EXPECT_TRUE(s.size() == 4); const span bs = as_bytes(s); - EXPECT_EQ(static_cast(bs.data()), static_cast(s.data())); - EXPECT_EQ(bs.size(), s.size_bytes()); + EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); + EXPECT_TRUE(bs.size() == s.size_bytes()); } { span s; const auto bs = as_bytes(s); - EXPECT_EQ(bs.size(), s.size()); - EXPECT_EQ(bs.size(), 0); - EXPECT_EQ(bs.size_bytes(), 0); - EXPECT_EQ(static_cast(bs.data()), static_cast(s.data())); - EXPECT_EQ(bs.data(), nullptr); + EXPECT_TRUE(bs.size() == s.size()); + EXPECT_TRUE(bs.size() == 0); + EXPECT_TRUE(bs.size_bytes() == 0); + EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); + EXPECT_TRUE(bs.data() == nullptr); } { span s = a; const auto bs = as_bytes(s); - EXPECT_EQ(static_cast(bs.data()), static_cast(s.data())); - EXPECT_EQ(bs.size(), s.size_bytes()); + EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); + EXPECT_TRUE(bs.size() == s.size_bytes()); } } @@ -1413,28 +1441,28 @@ TEST(span_test, from_array_constructor) #ifdef CONFIRM_COMPILATION_ERRORS // you should not be able to get writeable bytes for const objects span s = a; - EXPECT_EQ(s.size(), 4); + EXPECT_TRUE(s.size() == 4); span bs = as_writeable_bytes(s); - EXPECT_EQ(static_cast(bs.data()), static_cast(s.data())); - EXPECT_EQ(bs.size(), s.size_bytes()); + EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); + EXPECT_TRUE(bs.size() == s.size_bytes()); #endif } { span s; const auto bs = as_writeable_bytes(s); - EXPECT_EQ(bs.size(), s.size()); - EXPECT_EQ(bs.size(), 0); - EXPECT_EQ(bs.size_bytes(), 0); - EXPECT_EQ(static_cast(bs.data()), static_cast(s.data())); - EXPECT_EQ(bs.data(), nullptr); + EXPECT_TRUE(bs.size() == s.size()); + EXPECT_TRUE(bs.size() == 0); + EXPECT_TRUE(bs.size_bytes() == 0); + EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); + EXPECT_TRUE(bs.data() == nullptr); } { span s = a; const auto bs = as_writeable_bytes(s); - EXPECT_EQ(static_cast(bs.data()), static_cast(s.data())); - EXPECT_EQ(bs.size(), s.size_bytes()); + EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); + EXPECT_TRUE(bs.size() == s.size_bytes()); } } @@ -1444,12 +1472,12 @@ TEST(span_test, from_array_constructor) // converting to an span from an equal size array is ok span s4 = arr; - EXPECT_EQ(s4.size(), 4); + EXPECT_TRUE(s4.size() == 4); // converting to dynamic_range is always ok { span s = s4; - EXPECT_EQ(s.size(), s4.size()); + EXPECT_TRUE(s.size() == s4.size()); static_cast(s); } @@ -1533,22 +1561,23 @@ TEST(span_test, from_array_constructor) EXPECT_TRUE(match.ready()); EXPECT_FALSE(match.empty()); EXPECT_TRUE(match[0].matched); - EXPECT_EQ(match[0].first, s.begin()); - EXPECT_EQ(match[0].second, s.end()); + EXPECT_TRUE(match[0].first == s.begin()); + EXPECT_TRUE(match[0].second == s.end()); std::regex_search(s.begin(), s.end(), match, std::regex("F")); EXPECT_TRUE(match.ready()); EXPECT_FALSE(match.empty()); EXPECT_TRUE(match[0].matched); - EXPECT_EQ(match[0].first, f_it); - EXPECT_EQ(match[0].second, (f_it + 1)); + EXPECT_TRUE(match[0].first == f_it); + EXPECT_TRUE(match[0].second == (f_it + 1)); } TEST(span_test, interop_with_gsl_at) { int arr[5] = {1, 2, 3, 4, 5}; span s{arr}; - EXPECT_EQ(at(s, 0), 1); EXPECT_EQ(at(s, 1), 2); + EXPECT_TRUE(at(s, 0) == 1); + EXPECT_TRUE(at(s, 1) == 2); } TEST(span_test, default_constructible) diff --git a/tests/strict_notnull_tests.cpp b/tests/strict_notnull_tests.cpp index bbaddb2..08f9a3d 100644 --- a/tests/strict_notnull_tests.cpp +++ b/tests/strict_notnull_tests.cpp @@ -76,7 +76,7 @@ TEST(strict_notnull_tests, TestStrictNotNull) helper(snn1); helper_const(snn1); - EXPECT_EQ(*snn1, 42); + EXPECT_TRUE(*snn1 == 42); } { @@ -90,7 +90,7 @@ TEST(strict_notnull_tests, TestStrictNotNull) strict_helper_const(snn1); strict_helper_const(snn2); - EXPECT_EQ(snn1, snn2); + EXPECT_TRUE(snn1 == snn2); } { @@ -105,8 +105,8 @@ TEST(strict_notnull_tests, TestStrictNotNull) helper(snn); helper_const(snn); - EXPECT_EQ(snn, nn1); - EXPECT_EQ(snn, nn2); + EXPECT_TRUE(snn == nn1); + EXPECT_TRUE(snn == nn2); } { @@ -121,16 +121,16 @@ TEST(strict_notnull_tests, TestStrictNotNull) strict_helper(nn); strict_helper_const(nn); - EXPECT_EQ(snn1, nn); - EXPECT_EQ(snn2, nn); + EXPECT_TRUE(snn1 == nn); + EXPECT_TRUE(snn2 == nn); std::hash> hash_snn; std::hash> hash_nn; - EXPECT_EQ(hash_nn(snn1), hash_nn(nn)); - EXPECT_EQ(hash_snn(snn1), hash_nn(nn)); - EXPECT_EQ(hash_nn(snn1), hash_nn(snn2)); - EXPECT_EQ(hash_snn(snn1), hash_snn(nn)); + EXPECT_TRUE(hash_nn(snn1) == hash_nn(nn)); + EXPECT_TRUE(hash_snn(snn1) == hash_nn(nn)); + EXPECT_TRUE(hash_nn(snn1) == hash_nn(snn2)); + EXPECT_TRUE(hash_snn(snn1) == hash_snn(nn)); } #ifdef CONFIRM_COMPILATION_ERRORS @@ -151,7 +151,7 @@ TEST(strict_notnull_tests, TestStrictNotNullConstructorTypeDeduction) helper(strict_not_null{&i}); helper_const(strict_not_null{&i}); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { @@ -162,7 +162,7 @@ TEST(strict_notnull_tests, TestStrictNotNullConstructorTypeDeduction) helper(strict_not_null{p}); helper_const(strict_not_null{p}); - EXPECT_EQ(*x, 42); + EXPECT_TRUE(*x == 42); } { diff --git a/tests/strided_span_tests.cpp b/tests/strided_span_tests.cpp index 8c5b932..56ac88a 100644 --- a/tests/strided_span_tests.cpp +++ b/tests/strided_span_tests.cpp @@ -159,19 +159,21 @@ TEST(strided_span_tests, strided_span_constructors) strided_span sav1{arr, {{9}, {1}}}; // T -> T EXPECT_TRUE(sav1.bounds().index_bounds() == multi_span_index<1>{9}); EXPECT_TRUE(sav1.bounds().stride() == 1); - EXPECT_EQ(sav1[0], 1); EXPECT_EQ(sav1[8], 9); + EXPECT_TRUE(sav1[0] == 1); + EXPECT_TRUE(sav1[8] == 9); strided_span sav2{carr, {{4}, {2}}}; // const T -> const T EXPECT_TRUE(sav2.bounds().index_bounds() == multi_span_index<1>{4}); EXPECT_TRUE(sav2.bounds().strides() == multi_span_index<1>{2}); - EXPECT_EQ(sav2[0], 1); EXPECT_EQ(sav2[3], 7); + EXPECT_TRUE(sav2[0] == 1); + EXPECT_TRUE(sav2[3] == 7); strided_span sav3{arr, {{2, 2}, {6, 2}}}; // T -> const T EXPECT_TRUE((sav3.bounds().index_bounds() == multi_span_index<2>{2, 2})); EXPECT_TRUE((sav3.bounds().strides() == multi_span_index<2>{6, 2})); - EXPECT_EQ((sav3[{0, 0}]), 1); - EXPECT_EQ((sav3[{0, 1}]), 3); - EXPECT_EQ((sav3[{1, 0}]), 7); + EXPECT_TRUE((sav3[{0, 0}]) == 1); + EXPECT_TRUE((sav3[{0, 1}]) == 3); + EXPECT_TRUE((sav3[{1, 0}]) == 7); } // EXPECT_TRUE multi_span constructor @@ -310,8 +312,8 @@ TEST(strided_span_tests, strided_span_constructors) strided_span sav2{src2}; EXPECT_TRUE((sav2.bounds().index_bounds() == multi_span_index<2>{3, 2})); EXPECT_TRUE((sav2.bounds().strides() == multi_span_index<2>{2, 1})); - EXPECT_EQ((sav2[{0, 0}]), 1); - EXPECT_EQ((sav2[{2, 0}]), 5); + EXPECT_TRUE((sav2[{0, 0}]) == 1); + EXPECT_TRUE((sav2[{2, 0}]) == 5); } // EXPECT_TRUE const-casting assignment operator diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp index afa6ce3..d111d51 100644 --- a/tests/string_span_tests.cpp +++ b/tests/string_span_tests.cpp @@ -164,7 +164,7 @@ cu32zstring_span<> CreateTempNameU32(u32string_span<> span) TEST(string_span_tests, TestLiteralConstruction) { cwstring_span<> v = ensure_z(L"Hello"); - EXPECT_EQ(5, v.length()); + EXPECT_TRUE(5 == v.length()); #ifdef CONFIRM_COMPILATION_ERRORS wstring_span<> v2 = ensure0(L"Hello"); @@ -175,14 +175,14 @@ TEST(string_span_tests, TestConstructFromStdString) { std::string s = "Hello there world"; cstring_span<> v = s; - EXPECT_EQ(v.length(), static_cast::index_type>(s.length())); + EXPECT_TRUE(v.length() == static_cast::index_type>(s.length())); } TEST(string_span_tests, TestConstructFromStdVector) { std::vector vec(5, 'h'); string_span<> v{vec}; - EXPECT_EQ(v.length(), static_cast::index_type>(vec.size())); + EXPECT_TRUE(v.length() == static_cast::index_type>(vec.size())); } TEST(string_span_tests, TestStackArrayConstruction) @@ -191,22 +191,22 @@ TEST(string_span_tests, TestStackArrayConstruction) { cwstring_span<> v = ensure_z(stack_string); - EXPECT_EQ(v.length(), 5); + EXPECT_TRUE(v.length() == 5); } { cwstring_span<> v = stack_string; - EXPECT_EQ(v.length(), 5); + EXPECT_TRUE(v.length() == 5); } { wstring_span<> v = ensure_z(stack_string); - EXPECT_EQ(v.length(), 5); + EXPECT_TRUE(v.length() == 5); } { wstring_span<> v = stack_string; - EXPECT_EQ(v.length(), 5); + EXPECT_TRUE(v.length() == 5); } } @@ -214,7 +214,7 @@ TEST(string_span_tests, TestConstructFromConstCharPointer) { const char* s = "Hello"; cstring_span<> v = ensure_z(s); - EXPECT_EQ(v.length(), 5); + EXPECT_TRUE(v.length() == 5); } TEST(string_span_tests, TestConversionToConst) @@ -222,7 +222,7 @@ TEST(string_span_tests, TestConversionToConst) char stack_string[] = "Hello"; string_span<> v = ensure_z(stack_string); cstring_span<> v2 = v; - EXPECT_EQ(v.length(), v2.length()); + EXPECT_TRUE(v.length() == v2.length()); } TEST(string_span_tests, TestConversionFromConst) @@ -239,26 +239,26 @@ TEST(string_span_tests, TestConversionFromConst) TEST(string_span_tests, TestToString) { auto s = gsl::to_string(cstring_span<>{}); - EXPECT_EQ(s.length(), static_cast(0)); + EXPECT_TRUE(s.length() == static_cast(0)); char stack_string[] = "Hello"; cstring_span<> v = ensure_z(stack_string); auto s2 = gsl::to_string(v); - EXPECT_EQ(static_cast::index_type>(s2.length()), v.length()); - EXPECT_EQ(s2.length(), static_cast(5)); + EXPECT_TRUE(static_cast::index_type>(s2.length()) == v.length()); + EXPECT_TRUE(s2.length() == static_cast(5)); } TEST(string_span_tests, TestToBasicString) { auto s = gsl::to_basic_string, ::std::allocator>( cstring_span<>{}); - EXPECT_EQ(s.length(), static_cast(0)); + EXPECT_TRUE(s.length() == static_cast(0)); char stack_string[] = "Hello"; cstring_span<> v = ensure_z(stack_string); auto s2 = gsl::to_basic_string, ::std::allocator>(v); - EXPECT_EQ(static_cast::index_type>(s2.length()), v.length()); - EXPECT_EQ(s2.length(), static_cast(5)); + EXPECT_TRUE(static_cast::index_type>(s2.length()) == v.length()); + EXPECT_TRUE(s2.length() == static_cast(5)); } TEST(string_span_tests, EqualityAndImplicitConstructors) @@ -268,8 +268,8 @@ TEST(string_span_tests, EqualityAndImplicitConstructors) cstring_span<> span1; // comparison to empty span - EXPECT_NE(span1, span); - EXPECT_NE(span, span1); + EXPECT_TRUE(span1 != span); + EXPECT_TRUE(span != span1); } { @@ -277,8 +277,8 @@ TEST(string_span_tests, EqualityAndImplicitConstructors) cstring_span<> span1 = "Hello1"; // comparison to different span - EXPECT_NE(span1, span); - EXPECT_NE(span, span1); + EXPECT_TRUE(span1 != span); + EXPECT_TRUE(span != span1); } { @@ -293,31 +293,31 @@ TEST(string_span_tests, EqualityAndImplicitConstructors) gsl::span sp = ensure_z("Hello"); // comparison to literal - EXPECT_EQ(span, cstring_span<>("Hello")); + EXPECT_TRUE(span == cstring_span<>("Hello")); // comparison to static array with no null termination - EXPECT_EQ(span, cstring_span<>(ar)); + EXPECT_TRUE(span == cstring_span<>(ar)); // comparison to static array with null at the end - EXPECT_EQ(span, cstring_span<>(ar1)); + EXPECT_TRUE(span == cstring_span<>(ar1)); // comparison to static array with null in the middle - EXPECT_EQ(span, cstring_span<>(ar2)); + EXPECT_TRUE(span == cstring_span<>(ar2)); // comparison to null-terminated c string - EXPECT_EQ(span, cstring_span<>(ptr, 5)); + EXPECT_TRUE(span == cstring_span<>(ptr, 5)); // comparison to string - EXPECT_EQ(span, cstring_span<>(str)); + EXPECT_TRUE(span == cstring_span<>(str)); // comparison to vector of charaters with no null termination - EXPECT_EQ(span, cstring_span<>(vec)); + EXPECT_TRUE(span == cstring_span<>(vec)); // comparison to span - EXPECT_EQ(span, cstring_span<>(sp)); + EXPECT_TRUE(span == cstring_span<>(sp)); // comparison to string_span - EXPECT_EQ(span, span); + EXPECT_TRUE(span == span); } { @@ -333,28 +333,28 @@ TEST(string_span_tests, EqualityAndImplicitConstructors) gsl::span sp = ensure_z(ar1); // comparison to static array with no null termination - EXPECT_EQ(span, string_span<>(ar)); + EXPECT_TRUE(span == string_span<>(ar)); // comparison to static array with null at the end - EXPECT_EQ(span, string_span<>(ar1)); + EXPECT_TRUE(span == string_span<>(ar1)); // comparison to static array with null in the middle - EXPECT_EQ(span, string_span<>(ar2)); + EXPECT_TRUE(span == string_span<>(ar2)); // comparison to null-terminated c string - EXPECT_EQ(span, string_span<>(ptr, 5)); + EXPECT_TRUE(span == string_span<>(ptr, 5)); // comparison to string - EXPECT_EQ(span, string_span<>(str)); + EXPECT_TRUE(span == string_span<>(str)); // comparison to vector of charaters with no null termination - EXPECT_EQ(span, string_span<>(vec)); + EXPECT_TRUE(span == string_span<>(vec)); // comparison to span - EXPECT_EQ(span, string_span<>(sp)); + EXPECT_TRUE(span == string_span<>(sp)); // comparison to string_span - EXPECT_EQ(span, span); + EXPECT_TRUE(span == span); } { @@ -369,28 +369,28 @@ TEST(string_span_tests, EqualityAndImplicitConstructors) // const span, const other type - EXPECT_EQ(span, "Hello"); - EXPECT_EQ(span, ar); - EXPECT_EQ(span, ar1); - EXPECT_EQ(span, ar2); + EXPECT_TRUE(span == "Hello"); + EXPECT_TRUE(span == ar); + EXPECT_TRUE(span == ar1); + EXPECT_TRUE(span == ar2); #ifdef CONFIRM_COMPILATION_ERRORS const char* ptr = "Hello"; - EXPECT_EQ(span, ptr); + EXPECT_TRUE(span == ptr); #endif - EXPECT_EQ(span, str); - EXPECT_EQ(span, vec); - EXPECT_EQ(span, sp); + EXPECT_TRUE(span == str); + EXPECT_TRUE(span == vec); + EXPECT_TRUE(span == sp); - EXPECT_EQ("Hello", span); - EXPECT_EQ(ar, span); - EXPECT_EQ(ar1, span); - EXPECT_EQ(ar2, span); + EXPECT_TRUE("Hello" == span); + EXPECT_TRUE(ar == span); + EXPECT_TRUE(ar1 == span); + EXPECT_TRUE(ar2 == span); #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(ptr, span); + EXPECT_TRUE(ptr == span); #endif - EXPECT_EQ(str, span); - EXPECT_EQ(vec, span); - EXPECT_EQ(sp, span); + EXPECT_TRUE(str == span); + EXPECT_TRUE(vec == span); + EXPECT_TRUE(sp == span); // const span, non-const other type @@ -402,78 +402,78 @@ TEST(string_span_tests, EqualityAndImplicitConstructors) std::vector _vec = {'H', 'e', 'l', 'l', 'o'}; gsl::span _sp{_ar, 5}; - EXPECT_EQ(span, _ar); - EXPECT_EQ(span, _ar1); - EXPECT_EQ(span, _ar2); + EXPECT_TRUE(span == _ar); + EXPECT_TRUE(span == _ar1); + EXPECT_TRUE(span == _ar2); #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(span, _ptr); + EXPECT_TRUE(span == _ptr); #endif - EXPECT_EQ(span, _str); - EXPECT_EQ(span, _vec); - EXPECT_EQ(span, _sp); + EXPECT_TRUE(span == _str); + EXPECT_TRUE(span == _vec); + EXPECT_TRUE(span == _sp); - EXPECT_EQ(_ar, span); - EXPECT_EQ(_ar1, span); - EXPECT_EQ(_ar2, span); + EXPECT_TRUE(_ar == span); + EXPECT_TRUE(_ar1 == span); + EXPECT_TRUE(_ar2 == span); #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(_ptr, span); + EXPECT_TRUE(_ptr == span); #endif - EXPECT_EQ(_str, span); - EXPECT_EQ(_vec, span); - EXPECT_EQ(_sp, span); + EXPECT_TRUE(_str == span); + EXPECT_TRUE(_vec == span); + EXPECT_TRUE(_sp == span); string_span<> _span{_ptr, 5}; // non-const span, non-const other type - EXPECT_EQ(_span, _ar); - EXPECT_EQ(_span, _ar1); - EXPECT_EQ(_span, _ar2); + EXPECT_TRUE(_span == _ar); + EXPECT_TRUE(_span == _ar1); + EXPECT_TRUE(_span == _ar2); #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(_span, _ptr); + EXPECT_TRUE(_span == _ptr); #endif - EXPECT_EQ(_span, _str); - EXPECT_EQ(_span, _vec); - EXPECT_EQ(_span, _sp); + EXPECT_TRUE(_span == _str); + EXPECT_TRUE(_span == _vec); + EXPECT_TRUE(_span == _sp); - EXPECT_EQ(_ar, _span); - EXPECT_EQ(_ar1, _span); - EXPECT_EQ(_ar2, _span); + EXPECT_TRUE(_ar == _span); + EXPECT_TRUE(_ar1 == _span); + EXPECT_TRUE(_ar2 == _span); #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(_ptr, _span); + EXPECT_TRUE(_ptr == _span); #endif - EXPECT_EQ(_str, _span); - EXPECT_EQ(_vec, _span); - EXPECT_EQ(_sp, _span); + EXPECT_TRUE(_str == _span); + EXPECT_TRUE(_vec == _span); + EXPECT_TRUE(_sp == _span); // non-const span, const other type - EXPECT_EQ(_span, "Hello"); - EXPECT_EQ(_span, ar); - EXPECT_EQ(_span, ar1); - EXPECT_EQ(_span, ar2); + EXPECT_TRUE(_span == "Hello"); + EXPECT_TRUE(_span == ar); + EXPECT_TRUE(_span == ar1); + EXPECT_TRUE(_span == ar2); #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(_span, ptr); + EXPECT_TRUE(_span == ptr); #endif - EXPECT_EQ(_span, str); - EXPECT_EQ(_span, vec); - EXPECT_EQ(_span, sp); + EXPECT_TRUE(_span == str); + EXPECT_TRUE(_span == vec); + EXPECT_TRUE(_span == sp); - EXPECT_EQ("Hello", _span); - EXPECT_EQ(ar, _span); - EXPECT_EQ(ar1, _span); - EXPECT_EQ(ar2, _span); + EXPECT_TRUE("Hello" == _span); + EXPECT_TRUE(ar == _span); + EXPECT_TRUE(ar1 == _span); + EXPECT_TRUE(ar2 == _span); #ifdef CONFIRM_COMPILATION_ERRORS - EXPECT_EQ(ptr, _span); + EXPECT_TRUE(ptr == _span); #endif - EXPECT_EQ(str, _span); - EXPECT_EQ(vec, _span); - EXPECT_EQ(sp, _span); + EXPECT_TRUE(str == _span); + EXPECT_TRUE(vec == _span); + EXPECT_TRUE(sp == _span); // two spans - EXPECT_EQ(_span, span); - EXPECT_EQ(span, _span); + EXPECT_TRUE(_span == span); + EXPECT_TRUE(span == _span); } { @@ -483,7 +483,7 @@ TEST(string_span_tests, EqualityAndImplicitConstructors) cstring_span<> span2 = str2; // comparison of spans from the same vector before and after move (ok) - EXPECT_EQ(span1, span2); + EXPECT_TRUE(span1 == span2); } } @@ -500,26 +500,26 @@ TEST(string_span_tests, ComparisonAndImplicitConstructors) const std::vector vec = {'H', 'e', 'l', 'l', 'o'}; // comparison to literal - EXPECT_LT(span, cstring_span<>("Helloo")); - EXPECT_GT(span, cstring_span<>("Hell")); + EXPECT_TRUE(span < cstring_span<>("Helloo")); + EXPECT_TRUE(span > cstring_span<>("Hell")); // comparison to static array with no null termination - EXPECT_GE(span, cstring_span<>(ar)); + EXPECT_TRUE(span >= cstring_span<>(ar)); // comparison to static array with null at the end - EXPECT_LE(span, cstring_span<>(ar1)); + EXPECT_TRUE(span <= cstring_span<>(ar1)); // comparison to static array with null in the middle - EXPECT_GE(span, cstring_span<>(ar2)); + EXPECT_TRUE(span >= cstring_span<>(ar2)); // comparison to null-terminated c string - EXPECT_LE(span, cstring_span<>(ptr, 5)); + EXPECT_TRUE(span <= cstring_span<>(ptr, 5)); // comparison to string - EXPECT_GE(span, cstring_span<>(str)); + EXPECT_TRUE(span >= cstring_span<>(str)); // comparison to vector of charaters with no null termination - EXPECT_LE(span, cstring_span<>(vec)); + EXPECT_TRUE(span <= cstring_span<>(vec)); } { @@ -537,24 +537,24 @@ TEST(string_span_tests, ComparisonAndImplicitConstructors) std::vector vec = {'H', 'e', 'l', 'l', 'o'}; // comparison to static array with no null termination - EXPECT_LE(span, string_span<>(ar)); - EXPECT_LT(span, string_span<>(rarr)); - EXPECT_GT(span, string_span<>(larr)); + EXPECT_TRUE(span <= string_span<>(ar)); + EXPECT_TRUE(span < string_span<>(rarr)); + EXPECT_TRUE(span > string_span<>(larr)); // comparison to static array with null at the end - EXPECT_GE(span, string_span<>(ar1)); + EXPECT_TRUE(span >= string_span<>(ar1)); // comparison to static array with null in the middle - EXPECT_LE(span, string_span<>(ar2)); + EXPECT_TRUE(span <= string_span<>(ar2)); // comparison to null-terminated c string - EXPECT_GE(span, string_span<>(ptr, 5)); + EXPECT_TRUE(span >= string_span<>(ptr, 5)); // comparison to string - EXPECT_LE(span, string_span<>(str)); + EXPECT_TRUE(span <= string_span<>(str)); // comparison to vector of charaters with no null termination - EXPECT_GE(span, string_span<>(vec)); + EXPECT_TRUE(span >= string_span<>(vec)); } } @@ -563,14 +563,14 @@ TEST(string_span_tests, ConstrutorsEnsureZ) // remove z from literals { cstring_span<> sp = "hello"; - EXPECT_EQ(sp.length(), 5); + EXPECT_TRUE(sp.length() == 5); } // take the string as is { auto str = std::string("hello"); cstring_span<> sp = str; - EXPECT_EQ(sp.length(), 5); + EXPECT_TRUE(sp.length() == 5); } // ensure z on c strings @@ -582,7 +582,7 @@ TEST(string_span_tests, ConstrutorsEnsureZ) ptr[2] = '\0'; string_span<> span = ensure_z(ptr); - EXPECT_EQ(span.length(), 2); + EXPECT_TRUE(span.length() == 2); delete[] ptr; } @@ -596,7 +596,7 @@ TEST(string_span_tests, Constructors) { span sp = "Hello"; cstring_span<> span = sp; - EXPECT_EQ(span.length(), 6); + EXPECT_TRUE(span.length() == 6); } // from const span of a final extent to non-const string_span @@ -604,7 +604,7 @@ TEST(string_span_tests, Constructors) { span sp = "Hello"; string_span<> span = sp; - EXPECT_EQ(span.length(), 6); + EXPECT_TRUE(span.length() == 6); } #endif @@ -618,48 +618,48 @@ TEST(string_span_tests, Constructors) // default { cstring_span<> span; - EXPECT_EQ(span.length(), 0); + EXPECT_TRUE(span.length() == 0); } // from string literal { cstring_span<> span = "Hello"; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const static array { const char ar[] = {'H', 'e', 'l', 'l', 'o'}; cstring_span<> span = ar; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from non-const static array { char ar[] = {'H', 'e', 'l', 'l', 'o'}; cstring_span<> span = ar; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const ptr and length { const char* ptr = "Hello"; cstring_span<> span{ptr, 5}; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const ptr and length, include 0 { const char* ptr = "Hello"; cstring_span<> span{ptr, 6}; - EXPECT_EQ(span.length(), 6); + EXPECT_TRUE(span.length() == 6); } // from const ptr and length, 0 inside { const char* ptr = "He\0lo"; cstring_span<> span{ptr, 5}; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from non-const ptr and length @@ -667,7 +667,7 @@ TEST(string_span_tests, Constructors) char ar[] = {'H', 'e', 'l', 'l', 'o'}; char* ptr = ar; cstring_span<> span{ptr, 5}; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from non-const ptr and length, 0 inside @@ -675,35 +675,35 @@ TEST(string_span_tests, Constructors) char ar[] = {'H', 'e', '\0', 'l', 'o'}; char* ptr = ar; cstring_span<> span{ptr, 5}; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const string { const std::string str = "Hello"; const cstring_span<> span = str; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from non-const string { std::string str = "Hello"; const cstring_span<> span = str; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const vector { const std::vector vec = {'H', 'e', 'l', 'l', 'o'}; const cstring_span<> span = vec; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from non-const vector { std::vector vec = {'H', 'e', 'l', 'l', 'o'}; const cstring_span<> span = vec; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const span @@ -711,7 +711,7 @@ TEST(string_span_tests, Constructors) const std::vector vec = {'H', 'e', 'l', 'l', 'o'}; const span inner = vec; const cstring_span<> span = inner; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from non-const span @@ -719,7 +719,7 @@ TEST(string_span_tests, Constructors) std::vector vec = {'H', 'e', 'l', 'l', 'o'}; const span inner = vec; const cstring_span<> span = inner; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const string_span @@ -727,7 +727,7 @@ TEST(string_span_tests, Constructors) const std::vector vec = {'H', 'e', 'l', 'l', 'o'}; const cstring_span<> tmp = vec; const cstring_span<> span = tmp; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from non-const string_span @@ -735,7 +735,7 @@ TEST(string_span_tests, Constructors) std::vector vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> tmp = vec; cstring_span<> span = tmp; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // creating string_span @@ -752,7 +752,7 @@ TEST(string_span_tests, Constructors) #ifdef CONFIRM_COMPILATION_ERRORS const char ar[] = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = ar; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } @@ -760,7 +760,7 @@ TEST(string_span_tests, Constructors) { char ar[] = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = ar; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const ptr and length @@ -768,7 +768,7 @@ TEST(string_span_tests, Constructors) #ifdef CONFIRM_COMPILATION_ERRORS const char* ptr = "Hello"; string_span<> span{ptr, 5}; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } @@ -777,7 +777,7 @@ TEST(string_span_tests, Constructors) char ar[] = {'H', 'e', 'l', 'l', 'o'}; char* ptr = ar; string_span<> span{ptr, 5}; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const string @@ -785,7 +785,7 @@ TEST(string_span_tests, Constructors) #ifdef CONFIRM_COMPILATION_ERRORS const std::string str = "Hello"; string_span<> span = str; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } @@ -793,7 +793,7 @@ TEST(string_span_tests, Constructors) { std::string str = "Hello"; string_span<> span = str; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const vector @@ -801,7 +801,7 @@ TEST(string_span_tests, Constructors) #ifdef CONFIRM_COMPILATION_ERRORS const std::vector vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = vec; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } @@ -809,7 +809,7 @@ TEST(string_span_tests, Constructors) { std::vector vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = vec; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from const span @@ -818,7 +818,7 @@ TEST(string_span_tests, Constructors) std::vector vec = {'H', 'e', 'l', 'l', 'o'}; const span inner = vec; string_span<> span = inner; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } @@ -827,7 +827,7 @@ TEST(string_span_tests, Constructors) std::vector vec = {'H', 'e', 'l', 'l', 'o'}; span inner = vec; string_span<> span = inner; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from non-const span of non-const data from const vector @@ -836,7 +836,7 @@ TEST(string_span_tests, Constructors) const std::vector vec = {'H', 'e', 'l', 'l', 'o'}; const span inner = vec; string_span<> span = inner; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } @@ -846,7 +846,7 @@ TEST(string_span_tests, Constructors) std::vector vec = {'H', 'e', 'l', 'l', 'o'}; cstring_span<> tmp = vec; string_span<> span = tmp; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } @@ -855,7 +855,7 @@ TEST(string_span_tests, Constructors) std::vector vec = {'H', 'e', 'l', 'l', 'o'}; const string_span<> tmp = vec; const string_span<> span = tmp; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } // from non-const string_span from const vector @@ -864,7 +864,7 @@ TEST(string_span_tests, Constructors) const std::vector vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> tmp = vec; string_span<> span = tmp; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } @@ -873,7 +873,7 @@ TEST(string_span_tests, Constructors) std::vector vec = {'H', 'e', 'l', 'l', 'o'}; const string_span<> tmp = vec; const string_span<> span = tmp; - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); } } @@ -883,29 +883,29 @@ TEST(string_span_tests, MoveConstructors) { cstring_span<> span = "Hello"; const auto span1 = std::move(span); - EXPECT_EQ(span1.length(), 5); + EXPECT_TRUE(span1.length() == 5); } { cstring_span<> span = "Hello"; const auto span1 = move_wrapper(std::move(span)); - EXPECT_EQ(span1.length(), 5); + EXPECT_TRUE(span1.length() == 5); } { cstring_span<> span = "Hello"; const auto span1 = move_wrapper(std::move(span)); - EXPECT_EQ(span1.length(), 5); + EXPECT_TRUE(span1.length() == 5); } // move span { span span = ensure_z("Hello"); const cstring_span<> span1 = std::move(span); - EXPECT_EQ(span1.length(), 5); + EXPECT_TRUE(span1.length() == 5); } { span span = ensure_z("Hello"); const cstring_span<> span2 = move_wrapper(std::move(span)); - EXPECT_EQ(span2.length(), 5); + EXPECT_TRUE(span2.length() == 5); } // move string @@ -913,14 +913,14 @@ TEST(string_span_tests, MoveConstructors) #ifdef CONFIRM_COMPILATION_ERRORS std::string str = "Hello"; string_span<> span = std::move(str); - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } { #ifdef CONFIRM_COMPILATION_ERRORS std::string str = "Hello"; string_span<> span = move_wrapper(std::move(str)); - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } { @@ -934,14 +934,14 @@ TEST(string_span_tests, MoveConstructors) #ifdef CONFIRM_COMPILATION_ERRORS std::vector vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = std::move(vec); - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } { #ifdef CONFIRM_COMPILATION_ERRORS std::vector vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = move_wrapper>(std::move(vec)); - EXPECT_EQ(span.length(), 5); + EXPECT_TRUE(span.length() == 5); #endif } { @@ -956,7 +956,7 @@ TEST(string_span_tests, Conversion) #ifdef CONFIRM_COMPILATION_ERRORS cstring_span<> span = "Hello"; cwstring_span<> wspan{span}; - EXPECT_EQ(wspan.length(), 5); + EXPECT_TRUE(wspan.length() == 5); #endif } @@ -970,9 +970,9 @@ TEST(string_span_tests, zstring) zstring_span<> zspan({buf, 1}); - EXPECT_EQ(generic::strlen(zspan.assume_z()), 0); - EXPECT_EQ(zspan.as_string_span().size(), 0); - EXPECT_EQ(zspan.ensure_z().size(), 0); + EXPECT_TRUE(generic::strlen(zspan.assume_z()) == 0); + EXPECT_TRUE(zspan.as_string_span().size() == 0); + EXPECT_TRUE(zspan.ensure_z().size() == 0); } // create zspan from non-zero terminated string @@ -991,8 +991,8 @@ TEST(string_span_tests, zstring) auto name = CreateTempName({buf, 10}); if (!name.empty()) { czstring<> str = name.assume_z(); - EXPECT_EQ(generic::strlen(str), 3); - EXPECT_EQ(*(str + 3), '\0'); + EXPECT_TRUE(generic::strlen(str) == 3); + EXPECT_TRUE(*(str + 3) == '\0'); } } } @@ -1007,9 +1007,9 @@ TEST(string_span_tests, wzstring) wzstring_span<> zspan({buf, 1}); - EXPECT_EQ(generic::strnlen(zspan.assume_z(), 1), 0); - EXPECT_EQ(zspan.as_string_span().size(), 0); - EXPECT_EQ(zspan.ensure_z().size(), 0); + EXPECT_TRUE(generic::strnlen(zspan.assume_z(), 1) == 0); + EXPECT_TRUE(zspan.as_string_span().size() == 0); + EXPECT_TRUE(zspan.ensure_z().size() == 0); } // create zspan from non-zero terminated string @@ -1028,8 +1028,8 @@ TEST(string_span_tests, wzstring) const auto name = CreateTempNameW({buf, 10}); if (!name.empty()) { cwzstring<> str = name.assume_z(); - EXPECT_EQ(generic::strnlen(str, 10), 3); - EXPECT_EQ(*(str + 3), L'\0'); + EXPECT_TRUE(generic::strnlen(str, 10) == 3); + EXPECT_TRUE(*(str + 3) == L'\0'); } } } @@ -1044,9 +1044,9 @@ TEST(string_span_tests, u16zstring) u16zstring_span<> zspan({buf, 1}); - EXPECT_EQ(generic::strnlen(zspan.assume_z(), 1), 0); - EXPECT_EQ(zspan.as_string_span().size(), 0); - EXPECT_EQ(zspan.ensure_z().size(), 0); + EXPECT_TRUE(generic::strnlen(zspan.assume_z(), 1) == 0); + EXPECT_TRUE(zspan.as_string_span().size() == 0); + EXPECT_TRUE(zspan.ensure_z().size() == 0); } // create zspan from non-zero terminated string @@ -1065,8 +1065,8 @@ TEST(string_span_tests, u16zstring) const auto name = CreateTempNameU16({buf, 10}); if (!name.empty()) { cu16zstring<> str = name.assume_z(); - EXPECT_EQ(generic::strnlen(str, 10), 3); - EXPECT_EQ(*(str + 3), L'\0'); + EXPECT_TRUE(generic::strnlen(str, 10) == 3); + EXPECT_TRUE(*(str + 3) == L'\0'); } } } @@ -1081,9 +1081,9 @@ TEST(string_span_tests, u32zstring) u32zstring_span<> zspan({buf, 1}); - EXPECT_EQ(generic::strnlen(zspan.assume_z(), 1), 0); - EXPECT_EQ(zspan.as_string_span().size(), 0); - EXPECT_EQ(zspan.ensure_z().size(), 0); + EXPECT_TRUE(generic::strnlen(zspan.assume_z(), 1) == 0); + EXPECT_TRUE(zspan.as_string_span().size() == 0); + EXPECT_TRUE(zspan.ensure_z().size() == 0); } // create zspan from non-zero terminated string @@ -1102,8 +1102,8 @@ TEST(string_span_tests, u32zstring) const auto name = CreateTempNameU32({buf, 10}); if (!name.empty()) { cu32zstring<> str = name.assume_z(); - EXPECT_EQ(generic::strnlen(str, 10), 3); - EXPECT_EQ(*(str + 3), L'\0'); + EXPECT_TRUE(generic::strnlen(str, 10) == 3); + EXPECT_TRUE(*(str + 3) == L'\0'); } } } @@ -1111,86 +1111,86 @@ TEST(string_span_tests, u32zstring) TEST(string_span_tests, Issue305) { std::map, int> foo = {{"foo", 0}, {"bar", 1}}; - EXPECT_EQ(foo["foo"], 0); - EXPECT_EQ(foo["bar"], 1); + EXPECT_TRUE(foo["foo"] == 0); + EXPECT_TRUE(foo["bar"] == 1); } TEST(string_span_tests, char16_t_type) { gsl::cu16string_span<> ss1 = gsl::ensure_z(u"abc"); - EXPECT_EQ(ss1.size(), 3); - EXPECT_EQ(ss1.size_bytes(), 6); + EXPECT_TRUE(ss1.size() == 3); + EXPECT_TRUE(ss1.size_bytes() == 6); std::u16string s1 = gsl::to_string(ss1); - EXPECT_EQ(s1, u"abc"); + EXPECT_TRUE(s1 == u"abc"); std::u16string s2 = u"abc"; gsl::u16string_span<> ss2 = s2; - EXPECT_EQ(ss2.size(), 3); + EXPECT_TRUE(ss2.size() == 3); gsl::u16string_span<> ss3 = ss2.subspan(1, 1); - EXPECT_EQ(ss3.size(), 1); - EXPECT_EQ(ss3[0], u'b'); + EXPECT_TRUE(ss3.size() == 1); + EXPECT_TRUE(ss3[0] == u'b'); char16_t buf[4]{u'a', u'b', u'c', u'\0'}; gsl::u16string_span<> ss4{buf, 4}; - EXPECT_EQ(ss4[3], u'\0'); + EXPECT_TRUE(ss4[3] == u'\0'); gsl::cu16zstring_span<> ss5(u"abc"); - EXPECT_EQ((ss5.as_string_span().size()), 3); + EXPECT_TRUE((ss5.as_string_span().size()) == 3); gsl::cu16string_span<> ss6 = ss5.as_string_span(); - EXPECT_EQ(ss6, ss1); + EXPECT_TRUE(ss6 == ss1); std::vector v7 = {u'a', u'b', u'c'}; gsl::cu16string_span<> ss7{v7}; - EXPECT_EQ(ss7, ss1); + EXPECT_TRUE(ss7 == ss1); gsl::cu16string_span<> ss8 = gsl::ensure_z(u"abc"); gsl::cu16string_span<> ss9 = gsl::ensure_z(u"abc"); - EXPECT_EQ(ss8, ss9); + EXPECT_TRUE(ss8 == ss9); ss9 = gsl::ensure_z(u"abd"); - EXPECT_LT(ss8, ss9); - EXPECT_LE(ss8, ss9); - EXPECT_NE(ss8, ss9); + EXPECT_TRUE(ss8 < ss9); + EXPECT_TRUE(ss8 <= ss9); + EXPECT_TRUE(ss8 != ss9); } TEST(string_span_tests, char32_t_type) { gsl::cu32string_span<> ss1 = gsl::ensure_z(U"abc"); - EXPECT_EQ(ss1.size(), 3); - EXPECT_EQ(ss1.size_bytes(), 12); + EXPECT_TRUE(ss1.size() == 3); + EXPECT_TRUE(ss1.size_bytes() == 12); std::u32string s1 = gsl::to_string(ss1); - EXPECT_EQ(s1, U"abc"); + EXPECT_TRUE(s1 == U"abc"); std::u32string s2 = U"abc"; gsl::u32string_span<> ss2 = s2; - EXPECT_EQ(ss2.size(), 3); + EXPECT_TRUE(ss2.size() == 3); gsl::u32string_span<> ss3 = ss2.subspan(1, 1); - EXPECT_EQ(ss3.size(), 1); - EXPECT_EQ(ss3[0], U'b'); + EXPECT_TRUE(ss3.size() == 1); + EXPECT_TRUE(ss3[0] == U'b'); char32_t buf[4]{U'a', U'b', U'c', U'\0'}; gsl::u32string_span<> ss4{buf, 4}; - EXPECT_EQ(ss4[3], u'\0'); + EXPECT_TRUE(ss4[3] == u'\0'); gsl::cu32zstring_span<> ss5(U"abc"); - EXPECT_EQ(ss5.as_string_span().size(), 3); + EXPECT_TRUE(ss5.as_string_span().size() == 3); gsl::cu32string_span<> ss6 = ss5.as_string_span(); - EXPECT_EQ(ss6, ss1); + EXPECT_TRUE(ss6 == ss1); gsl::cu32string_span<> ss8 = gsl::ensure_z(U"abc"); gsl::cu32string_span<> ss9 = gsl::ensure_z(U"abc"); - EXPECT_EQ(ss8, ss9); + EXPECT_TRUE(ss8 == ss9); ss9 = gsl::ensure_z(U"abd"); - EXPECT_LT(ss8, ss9); - EXPECT_LE(ss8, ss9); - EXPECT_NE(ss8, ss9); + EXPECT_TRUE(ss8 < ss9); + EXPECT_TRUE(ss8 <= ss9); + EXPECT_TRUE(ss8 != ss9); } TEST(string_span_tests, as_bytes) @@ -1198,8 +1198,8 @@ TEST(string_span_tests, as_bytes) cwzstring_span<> v(L"qwerty"); const auto s = v.as_string_span(); const auto bs = as_bytes(s); - EXPECT_EQ(static_cast(bs.data()), static_cast(s.data())); - EXPECT_EQ(bs.size(), s.size_bytes()); + EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); + EXPECT_TRUE(bs.size() == s.size_bytes()); } TEST(string_span_tests, as_writeable_bytes) @@ -1208,8 +1208,8 @@ TEST(string_span_tests, as_writeable_bytes) wzstring_span<> v(buf); const auto s = v.as_string_span(); const auto bs = as_writeable_bytes(s); - EXPECT_EQ(static_cast(bs.data()), static_cast(s.data())); - EXPECT_EQ(bs.size(), s.size_bytes()); + EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); + EXPECT_TRUE(bs.size() == s.size_bytes()); } #if __clang__ || __GNUC__ diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index 9cf59cd..add1fac 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -57,9 +57,9 @@ TEST(utils_tests, finally_lambda) int i = 0; { auto _ = finally([&]() { f(i); }); - EXPECT_EQ(i, 0); + EXPECT_TRUE(i == 0); } - EXPECT_EQ(i, 1); + EXPECT_TRUE(i == 1); } TEST(utils_tests, finally_lambda_move) @@ -69,16 +69,16 @@ TEST(utils_tests, finally_lambda_move) auto _1 = finally([&]() { f(i); }); { auto _2 = std::move(_1); - EXPECT_EQ(i, 0); + EXPECT_TRUE(i == 0); } - EXPECT_EQ(i, 1); + EXPECT_TRUE(i == 1); { auto _2 = std::move(_1); - EXPECT_EQ(i, 1); + EXPECT_TRUE(i == 1); } - EXPECT_EQ(i, 1); + EXPECT_TRUE(i == 1); } - EXPECT_EQ(i, 1); + EXPECT_TRUE(i == 1); } TEST(utils_tests, finally_function_with_bind) @@ -86,9 +86,9 @@ TEST(utils_tests, finally_function_with_bind) int i = 0; { auto _ = finally(std::bind(&f, std::ref(i))); - EXPECT_EQ(i, 0); + EXPECT_TRUE(i == 0); } - EXPECT_EQ(i, 1); + EXPECT_TRUE(i == 1); } TEST(utils_tests, finally_function_ptr) @@ -96,27 +96,27 @@ TEST(utils_tests, finally_function_ptr) j = 0; { auto _ = finally(&g); - EXPECT_EQ(j, 0); + EXPECT_TRUE(j == 0); } - EXPECT_EQ(j, 1); + EXPECT_TRUE(j == 1); } TEST(utils_tests, narrow_cast) { int n = 120; char c = narrow_cast(n); - EXPECT_EQ(c, 120); + EXPECT_TRUE(c == 120); n = 300; unsigned char uc = narrow_cast(n); - EXPECT_EQ(uc, 44); + EXPECT_TRUE(uc == 44); } TEST(utils_tests, narrow) { int n = 120; const char c = narrow(n); - EXPECT_EQ(c, 120); + EXPECT_TRUE(c == 120); n = 300; EXPECT_DEATH(narrow(n), ".*");