attempting to fix the gtest print issues in vs17

This commit is contained in:
Jordan Maples [MSFT] 2019-12-04 13:46:50 -08:00
parent 87eaa45445
commit b39a9732f8
12 changed files with 1060 additions and 1029 deletions

View File

@ -57,8 +57,8 @@ TEST(algorithm_tests, same_type)
copy(src_span, dst_span.subspan(src_span.size())); copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) { for (std::size_t i = 0; i < src.size(); ++i) {
EXPECT_EQ(dst[i], src[i]); EXPECT_TRUE(dst[i] == src[i]);
EXPECT_EQ(dst[i + src.size()], 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())); copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) { for (std::size_t i = 0; i < src.size(); ++i) {
EXPECT_EQ(dst[i], src[i]); EXPECT_TRUE(dst[i] == src[i]);
EXPECT_EQ(dst[i + src.size()], 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())); copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) { for (std::size_t i = 0; i < src.size(); ++i) {
EXPECT_EQ(dst[i], src[i]); EXPECT_TRUE(dst[i] == src[i]);
EXPECT_EQ(dst[i + src.size()], 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())); copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) { for (std::size_t i = 0; i < src.size(); ++i) {
EXPECT_EQ(dst[i], src[i]); EXPECT_TRUE(dst[i] == src[i]);
EXPECT_EQ(dst[i + src.size()], 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())); copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) { for (std::size_t i = 0; i < src.size(); ++i) {
EXPECT_EQ(dst[i], src[i]); EXPECT_TRUE(dst[i] == src[i]);
EXPECT_EQ(dst[i + src.size()], 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())); copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) { for (std::size_t i = 0; i < src.size(); ++i) {
EXPECT_EQ(dst[i], src[i]); EXPECT_TRUE(dst[i] == src[i]);
EXPECT_EQ(dst[i + src.size()], 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())); copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) { for (std::size_t i = 0; i < src.size(); ++i) {
EXPECT_EQ(dst[i], src[i]); EXPECT_TRUE(dst[i] == src[i]);
EXPECT_EQ(dst[i + src.size()], 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())); copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) { for (std::size_t i = 0; i < src.size(); ++i) {
EXPECT_EQ(dst[i], src[i]); EXPECT_TRUE(dst[i] == src[i]);
EXPECT_EQ(dst[i + src.size()], src[i]); EXPECT_TRUE(dst[i + src.size()] == src[i]);
} }
} }
} }

View File

@ -53,14 +53,14 @@ int g(int i)
TEST(assertion_tests, expects) TEST(assertion_tests, expects)
{ {
EXPECT_EQ(f(2), 2); EXPECT_TRUE(f(2) == 2);
EXPECT_DEATH(f(10), ".*"); EXPECT_DEATH(f(10), ".*");
} }
TEST(assertion_tests, ensures) TEST(assertion_tests, ensures)
{ {
EXPECT_EQ(g(2), 3); EXPECT_TRUE(g(2) == 3);
EXPECT_DEATH(g(9), ".*"); EXPECT_DEATH(g(9), ".*");
} }

View File

@ -44,8 +44,8 @@ TEST(at_tests, static_array)
const int(&c_a)[4] = a; const int(&c_a)[4] = a;
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
EXPECT_EQ(&gsl::at(a, i), &a[i]); EXPECT_TRUE(&gsl::at(a, i) == &a[i]);
EXPECT_EQ(&gsl::at(c_a, i), &a[i]); EXPECT_TRUE(&gsl::at(c_a, i) == &a[i]);
} }
EXPECT_DEATH(gsl::at(a, -1), ".*"); EXPECT_DEATH(gsl::at(a, -1), ".*");
@ -60,8 +60,8 @@ TEST(at_tests, std_array)
const std::array<int, 4>& c_a = a; const std::array<int, 4>& c_a = a;
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
EXPECT_EQ(&gsl::at(a, i), &a[static_cast<std::size_t>(i)]); EXPECT_TRUE(&gsl::at(a, i) == &a[static_cast<std::size_t>(i)]);
EXPECT_EQ(&gsl::at(c_a, i), &a[static_cast<std::size_t>(i)]); EXPECT_TRUE(&gsl::at(c_a, i) == &a[static_cast<std::size_t>(i)]);
} }
EXPECT_DEATH(gsl::at(a, -1), ".*"); EXPECT_DEATH(gsl::at(a, -1), ".*");
@ -76,8 +76,8 @@ TEST(at_tests, StdVector)
const std::vector<int>& c_a = a; const std::vector<int>& c_a = a;
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
EXPECT_EQ(&gsl::at(a, i), &a[static_cast<std::size_t>(i)]); EXPECT_TRUE(&gsl::at(a, i) == &a[static_cast<std::size_t>(i)]);
EXPECT_EQ(&gsl::at(c_a, i), &a[static_cast<std::size_t>(i)]); EXPECT_TRUE(&gsl::at(c_a, i) == &a[static_cast<std::size_t>(i)]);
} }
EXPECT_DEATH(gsl::at(a, -1), ".*"); EXPECT_DEATH(gsl::at(a, -1), ".*");
@ -91,8 +91,8 @@ TEST(at_tests, InitializerList)
const std::initializer_list<int> a = {1, 2, 3, 4}; const std::initializer_list<int> a = {1, 2, 3, 4};
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
EXPECT_EQ(gsl::at(a, i), i + 1); EXPECT_TRUE(gsl::at(a, i) == i + 1);
EXPECT_EQ(gsl::at({1, 2, 3, 4}, i), i + 1); EXPECT_TRUE(gsl::at({1, 2, 3, 4}, i) == i + 1);
} }
EXPECT_DEATH(gsl::at(a, -1), ".*"); EXPECT_DEATH(gsl::at(a, -1), ".*");

View File

@ -110,8 +110,8 @@ TEST(bounds_tests, bounds_convertible)
b5 = static_bounds<34>(); b5 = static_bounds<34>();
b6 = b5; b6 = b5;
EXPECT_EQ(b5, b6); EXPECT_TRUE(b5 == b6);
EXPECT_EQ(b5.size(), b6.size()); EXPECT_TRUE(b5.size() == b6.size());
} }
#ifdef CONFIRM_COMPILATION_ERRORS #ifdef CONFIRM_COMPILATION_ERRORS

File diff suppressed because it is too large Load Diff

View File

@ -166,7 +166,7 @@ TEST(notnull_tests, TestNotNullConstructors)
int i = 12; int i = 12;
auto rp = RefCounted<int>(&i); auto rp = RefCounted<int>(&i);
not_null<int*> p(rp); not_null<int*> p(rp);
EXPECT_EQ(p.get(), &i); EXPECT_TRUE(p.get() == &i);
not_null<std::shared_ptr<int>> x( not_null<std::shared_ptr<int>> x(
std::make_shared<int>(10)); // shared_ptr<int> is nullptr assignable std::make_shared<int>(10)); // shared_ptr<int> is nullptr assignable
@ -183,7 +183,7 @@ TEST(notnull_tests, TestNotNullConstructors)
helper(&t); helper(&t);
helper_const(&t); helper_const(&t);
EXPECT_EQ(*x, 42); EXPECT_TRUE(*x == 42);
} }
{ {
@ -199,7 +199,7 @@ TEST(notnull_tests, TestNotNullConstructors)
helper(x); helper(x);
helper_const(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(cp);
helper_const(x); helper_const(x);
EXPECT_EQ(*x, 42); EXPECT_TRUE(*x == 42);
} }
{ {
@ -223,7 +223,7 @@ TEST(notnull_tests, TestNotNullConstructors)
auto x = not_null<const int*>{cp}; auto x = not_null<const int*>{cp};
EXPECT_EQ(*x, 42); EXPECT_TRUE(*x == 42);
} }
{ {
@ -243,14 +243,14 @@ void ostream_helper(T v)
std::ostringstream ref; std::ostringstream ref;
os << static_cast<void*>(p); os << static_cast<void*>(p);
ref << static_cast<void*>(&v); ref << static_cast<void*>(&v);
EXPECT_EQ(os.str(), ref.str()); EXPECT_TRUE(os.str() == ref.str());
} }
{ {
std::ostringstream os; std::ostringstream os;
std::ostringstream ref; std::ostringstream ref;
os << *p; os << *p;
ref << v; ref << v;
EXPECT_EQ(os.str(), ref.str()); EXPECT_TRUE(os.str() == ref.str());
} }
} }
@ -275,7 +275,7 @@ TEST(notnull_tests, TestNotNullCasting)
not_null<MyDerived*> p{&derived}; not_null<MyDerived*> p{&derived};
not_null<MyBase*> q(&base); not_null<MyBase*> q(&base);
q = p; // allowed with heterogeneous copy ctor q = p; // allowed with heterogeneous copy ctor
EXPECT_EQ(q, p); EXPECT_TRUE(q == p);
#ifdef CONFIRM_COMPILATION_ERRORS #ifdef CONFIRM_COMPILATION_ERRORS
q = u; // no viable conversion possible between MyBase* and Unrelated* q = u; // no viable conversion possible between MyBase* and Unrelated*
@ -285,7 +285,7 @@ TEST(notnull_tests, TestNotNullCasting)
not_null<Unrelated*> s = reinterpret_cast<Unrelated*>(p); not_null<Unrelated*> s = reinterpret_cast<Unrelated*>(p);
#endif #endif
not_null<Unrelated*> t(reinterpret_cast<Unrelated*>(p.get())); not_null<Unrelated*> t(reinterpret_cast<Unrelated*>(p.get()));
EXPECT_EQ(reinterpret_cast<void*>(p.get()), reinterpret_cast<void*>(t.get())); EXPECT_TRUE(reinterpret_cast<void*>(p.get()) == reinterpret_cast<void*>(t.get()));
} }
TEST(notnull_tests, TestNotNullAssignment) TEST(notnull_tests, TestNotNullAssignment)
@ -307,23 +307,23 @@ TEST(notnull_tests, TestNotNullRawPointerComparison)
using NotNull1 = not_null<decltype(p1)>; using NotNull1 = not_null<decltype(p1)>;
using NotNull2 = not_null<decltype(p2)>; using NotNull2 = not_null<decltype(p2)>;
EXPECT_EQ((NotNull1(p1) == NotNull1(p1)), true); EXPECT_TRUE((NotNull1(p1) == NotNull1(p1)) == true);
EXPECT_EQ((NotNull1(p1) == NotNull2(p2)), false); EXPECT_TRUE((NotNull1(p1) == NotNull2(p2)) == false);
EXPECT_EQ((NotNull1(p1) != NotNull1(p1)), false); EXPECT_TRUE((NotNull1(p1) != NotNull1(p1)) == false);
EXPECT_EQ((NotNull1(p1) != NotNull2(p2)), true); EXPECT_TRUE((NotNull1(p1) != NotNull2(p2)) == true);
EXPECT_EQ((NotNull1(p1) < NotNull1(p1)), false); EXPECT_TRUE((NotNull1(p1) < NotNull1(p1)) == false);
EXPECT_EQ((NotNull1(p1) < NotNull2(p2)), (p1 < p2)); EXPECT_TRUE((NotNull1(p1) < NotNull2(p2)) == (p1 < p2));
EXPECT_EQ((NotNull2(p2) < NotNull1(p1)), (p2 < p1)); EXPECT_TRUE((NotNull2(p2) < NotNull1(p1)) == (p2 < p1));
EXPECT_EQ((NotNull1(p1) > NotNull1(p1)), false); EXPECT_TRUE((NotNull1(p1) > NotNull1(p1)) == false);
EXPECT_EQ((NotNull1(p1) > NotNull2(p2)), (p1 > p2)); EXPECT_TRUE((NotNull1(p1) > NotNull2(p2)) == (p1 > p2));
EXPECT_EQ((NotNull2(p2) > NotNull1(p1)), (p2 > p1)); EXPECT_TRUE((NotNull2(p2) > NotNull1(p1)) == (p2 > p1));
EXPECT_EQ((NotNull1(p1) <= NotNull1(p1)), true); EXPECT_TRUE((NotNull1(p1) <= NotNull1(p1)) == true);
EXPECT_EQ((NotNull1(p1) <= NotNull2(p2)), (p1 <= p2)); EXPECT_TRUE((NotNull1(p1) <= NotNull2(p2)) == (p1 <= p2));
EXPECT_EQ((NotNull2(p2) <= NotNull1(p1)), (p2 <= p1)); EXPECT_TRUE((NotNull2(p2) <= NotNull1(p1)) == (p2 <= p1));
} }
TEST(notnull_tests, TestNotNullDereferenceOperator) TEST(notnull_tests, TestNotNullDereferenceOperator)
@ -332,8 +332,8 @@ TEST(notnull_tests, TestNotNullDereferenceOperator)
auto sp1 = std::make_shared<NonCopyableNonMovable>(); auto sp1 = std::make_shared<NonCopyableNonMovable>();
using NotNullSp1 = not_null<decltype(sp1)>; using NotNullSp1 = not_null<decltype(sp1)>;
EXPECT_EQ(typeid(*sp1), typeid(*NotNullSp1(sp1))); EXPECT_TRUE(typeid(*sp1) == typeid(*NotNullSp1(sp1)));
EXPECT_EQ(std::addressof(*NotNullSp1(sp1)), std::addressof(*sp1)); EXPECT_TRUE(std::addressof(*NotNullSp1(sp1)) == std::addressof(*sp1));
} }
{ {
@ -341,18 +341,18 @@ TEST(notnull_tests, TestNotNullDereferenceOperator)
CustomPtr<int> p1(&ints[0]); CustomPtr<int> p1(&ints[0]);
using NotNull1 = not_null<decltype(p1)>; using NotNull1 = not_null<decltype(p1)>;
EXPECT_EQ(typeid(*NotNull1(p1)), typeid(*p1)); EXPECT_TRUE(typeid(*NotNull1(p1)) == typeid(*p1));
EXPECT_EQ(*NotNull1(p1), 42); EXPECT_TRUE(*NotNull1(p1) == 42);
*NotNull1(p1) = 43; *NotNull1(p1) = 43;
EXPECT_EQ(ints[0], 43); EXPECT_TRUE(ints[0] == 43);
} }
{ {
int v = 42; int v = 42;
gsl::not_null<int*> p(&v); gsl::not_null<int*> p(&v);
EXPECT_EQ(typeid(*p), typeid(*(&v))); EXPECT_TRUE(typeid(*p) == typeid(*(&v)));
*p = 43; *p = 43;
EXPECT_EQ(v, 43); EXPECT_TRUE(v == 43);
} }
} }
@ -364,27 +364,27 @@ TEST(notnull_tests, TestNotNullSharedPtrComparison)
using NotNullSp1 = not_null<decltype(sp1)>; using NotNullSp1 = not_null<decltype(sp1)>;
using NotNullSp2 = not_null<decltype(sp2)>; using NotNullSp2 = not_null<decltype(sp2)>;
EXPECT_EQ((NotNullSp1(sp1) == NotNullSp1(sp1)), true); EXPECT_TRUE((NotNullSp1(sp1) == NotNullSp1(sp1)) == true);
EXPECT_EQ((NotNullSp1(sp1) == NotNullSp2(sp2)), false); EXPECT_TRUE((NotNullSp1(sp1) == NotNullSp2(sp2)) == false);
EXPECT_EQ((NotNullSp1(sp1) != NotNullSp1(sp1)), false); EXPECT_TRUE((NotNullSp1(sp1) != NotNullSp1(sp1)) == false);
EXPECT_EQ((NotNullSp1(sp1) != NotNullSp2(sp2)), true); EXPECT_TRUE((NotNullSp1(sp1) != NotNullSp2(sp2)) == true);
EXPECT_EQ((NotNullSp1(sp1) < NotNullSp1(sp1)), false); EXPECT_TRUE((NotNullSp1(sp1) < NotNullSp1(sp1)) == false);
EXPECT_EQ((NotNullSp1(sp1) < NotNullSp2(sp2)), (sp1 < sp2)); EXPECT_TRUE((NotNullSp1(sp1) < NotNullSp2(sp2)) == (sp1 < sp2));
EXPECT_EQ((NotNullSp2(sp2) < NotNullSp1(sp1)), (sp2 < sp1)); EXPECT_TRUE((NotNullSp2(sp2) < NotNullSp1(sp1)) == (sp2 < sp1));
EXPECT_EQ((NotNullSp1(sp1) > NotNullSp1(sp1)), false); EXPECT_TRUE((NotNullSp1(sp1) > NotNullSp1(sp1)) == false);
EXPECT_EQ((NotNullSp1(sp1) > NotNullSp2(sp2)), (sp1 > sp2)); EXPECT_TRUE((NotNullSp1(sp1) > NotNullSp2(sp2)) == (sp1 > sp2));
EXPECT_EQ((NotNullSp2(sp2) > NotNullSp1(sp1)), (sp2 > sp1)); EXPECT_TRUE((NotNullSp2(sp2) > NotNullSp1(sp1)) == (sp2 > sp1));
EXPECT_EQ((NotNullSp1(sp1) <= NotNullSp1(sp1)), true); EXPECT_TRUE((NotNullSp1(sp1) <= NotNullSp1(sp1)) == true);
EXPECT_EQ((NotNullSp1(sp1) <= NotNullSp2(sp2)), (sp1 <= sp2)); EXPECT_TRUE((NotNullSp1(sp1) <= NotNullSp2(sp2)) == (sp1 <= sp2));
EXPECT_EQ((NotNullSp2(sp2) <= NotNullSp1(sp1)), (sp2 <= sp1)); EXPECT_TRUE((NotNullSp2(sp2) <= NotNullSp1(sp1)) == (sp2 <= sp1));
EXPECT_EQ((NotNullSp1(sp1) >= NotNullSp1(sp1)), true); EXPECT_TRUE((NotNullSp1(sp1) >= NotNullSp1(sp1)) == true);
EXPECT_EQ((NotNullSp1(sp1) >= NotNullSp2(sp2)), (sp1 >= sp2)); EXPECT_TRUE((NotNullSp1(sp1) >= NotNullSp2(sp2)) == (sp1 >= sp2));
EXPECT_EQ((NotNullSp2(sp2) >= NotNullSp1(sp1)), (sp2 >= sp1)); EXPECT_TRUE((NotNullSp2(sp2) >= NotNullSp1(sp1)) == (sp2 >= sp1));
} }
TEST(notnull_tests, TestNotNullCustomPtrComparison) TEST(notnull_tests, TestNotNullCustomPtrComparison)
@ -396,27 +396,27 @@ TEST(notnull_tests, TestNotNullCustomPtrComparison)
using NotNull1 = not_null<decltype(p1)>; using NotNull1 = not_null<decltype(p1)>;
using NotNull2 = not_null<decltype(p2)>; using NotNull2 = not_null<decltype(p2)>;
EXPECT_EQ((NotNull1(p1) == NotNull1(p1)), "true"); EXPECT_TRUE((NotNull1(p1) == NotNull1(p1)) == "true");
EXPECT_EQ((NotNull1(p1) == NotNull2(p2)), "false"); EXPECT_TRUE((NotNull1(p1) == NotNull2(p2)) == "false");
EXPECT_EQ((NotNull1(p1) != NotNull1(p1)), "false"); EXPECT_TRUE((NotNull1(p1) != NotNull1(p1)) == "false");
EXPECT_EQ((NotNull1(p1) != NotNull2(p2)), "true"); EXPECT_TRUE((NotNull1(p1) != NotNull2(p2)) == "true");
EXPECT_EQ((NotNull1(p1) < NotNull1(p1)), "false"); EXPECT_TRUE((NotNull1(p1) < NotNull1(p1)) == "false");
EXPECT_EQ((NotNull1(p1) < NotNull2(p2)), (p1 < p2)); EXPECT_TRUE((NotNull1(p1) < NotNull2(p2)) == (p1 < p2));
EXPECT_EQ((NotNull2(p2) < NotNull1(p1)), (p2 < p1)); EXPECT_TRUE((NotNull2(p2) < NotNull1(p1)) == (p2 < p1));
EXPECT_EQ((NotNull1(p1) > NotNull1(p1)), "false"); EXPECT_TRUE((NotNull1(p1) > NotNull1(p1)) == "false");
EXPECT_EQ((NotNull1(p1) > NotNull2(p2)), (p1 > p2)); EXPECT_TRUE((NotNull1(p1) > NotNull2(p2)) == (p1 > p2));
EXPECT_EQ((NotNull2(p2) > NotNull1(p1)), (p2 > p1)); EXPECT_TRUE((NotNull2(p2) > NotNull1(p1)) == (p2 > p1));
EXPECT_EQ((NotNull1(p1) <= NotNull1(p1)), "true"); EXPECT_TRUE((NotNull1(p1) <= NotNull1(p1)) == "true");
EXPECT_EQ((NotNull1(p1) <= NotNull2(p2)), (p1 <= p2)); EXPECT_TRUE((NotNull1(p1) <= NotNull2(p2)) == (p1 <= p2));
EXPECT_EQ((NotNull2(p2) <= NotNull1(p1)), (p2 <= p1)); EXPECT_TRUE((NotNull2(p2) <= NotNull1(p1)) == (p2 <= p1));
EXPECT_EQ((NotNull1(p1) >= NotNull1(p1)), "true"); EXPECT_TRUE((NotNull1(p1) >= NotNull1(p1)) == "true");
EXPECT_EQ((NotNull1(p1) >= NotNull2(p2)), (p1 >= p2)); EXPECT_TRUE((NotNull1(p1) >= NotNull2(p2)) == (p1 >= p2));
EXPECT_EQ((NotNull2(p2) >= NotNull1(p1)), (p2 >= p1)); EXPECT_TRUE((NotNull2(p2) >= NotNull1(p1)) == (p2 >= p1));
} }
#if defined(__cplusplus) && (__cplusplus >= 201703L) #if defined(__cplusplus) && (__cplusplus >= 201703L)
@ -430,7 +430,7 @@ TEST(notnull_tests, TestNotNullConstructorTypeDeduction)
helper(not_null{&i}); helper(not_null{&i});
helper_const(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(not_null{p});
helper_const(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(make_not_null(&i));
helper_const(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(make_not_null(p));
helper_const(make_not_null(p)); helper_const(make_not_null(p));
EXPECT_EQ(*x, 42); EXPECT_TRUE(*x == 42);
} }
{ {
const auto workaround_macro = []() { const auto workaround_macro = []() {
int* p1 = nullptr; int* p1 = nullptr;
const auto x = make_not_null(p1); const auto x = make_not_null(p1);
EXPECT_EQ(*x, 42); EXPECT_TRUE(*x == 42);
}; };
EXPECT_DEATH(workaround_macro(), ".*"); EXPECT_DEATH(workaround_macro(), ".*");
} }
@ -513,7 +513,7 @@ TEST(notnull_tests, TestMakeNotNull)
const auto workaround_macro = []() { const auto workaround_macro = []() {
const int* p1 = nullptr; const int* p1 = nullptr;
const auto x = make_not_null(p1); const auto x = make_not_null(p1);
EXPECT_EQ(*x, 42); EXPECT_TRUE(*x == 42);
}; };
EXPECT_DEATH(workaround_macro(), ".*"); EXPECT_DEATH(workaround_macro(), ".*");
} }

View File

@ -42,9 +42,9 @@ void f(int* i) { *i += 1; }
TEST(owner_tests, basic_test) TEST(owner_tests, basic_test)
{ {
owner<int*> p = new int(120); owner<int*> p = new int(120);
EXPECT_EQ(*p, 120); EXPECT_TRUE(*p == 120);
f(p); f(p);
EXPECT_EQ(*p, 121); EXPECT_TRUE(*p == 121);
delete p; delete p;
} }

File diff suppressed because it is too large Load Diff

View File

@ -76,7 +76,7 @@ TEST(strict_notnull_tests, TestStrictNotNull)
helper(snn1); helper(snn1);
helper_const(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(snn1);
strict_helper_const(snn2); strict_helper_const(snn2);
EXPECT_EQ(snn1, snn2); EXPECT_TRUE(snn1 == snn2);
} }
{ {
@ -105,8 +105,8 @@ TEST(strict_notnull_tests, TestStrictNotNull)
helper(snn); helper(snn);
helper_const(snn); helper_const(snn);
EXPECT_EQ(snn, nn1); EXPECT_TRUE(snn == nn1);
EXPECT_EQ(snn, nn2); EXPECT_TRUE(snn == nn2);
} }
{ {
@ -121,16 +121,16 @@ TEST(strict_notnull_tests, TestStrictNotNull)
strict_helper(nn); strict_helper(nn);
strict_helper_const(nn); strict_helper_const(nn);
EXPECT_EQ(snn1, nn); EXPECT_TRUE(snn1 == nn);
EXPECT_EQ(snn2, nn); EXPECT_TRUE(snn2 == nn);
std::hash<strict_not_null<int*>> hash_snn; std::hash<strict_not_null<int*>> hash_snn;
std::hash<not_null<int*>> hash_nn; std::hash<not_null<int*>> hash_nn;
EXPECT_EQ(hash_nn(snn1), hash_nn(nn)); EXPECT_TRUE(hash_nn(snn1) == hash_nn(nn));
EXPECT_EQ(hash_snn(snn1), hash_nn(nn)); EXPECT_TRUE(hash_snn(snn1) == hash_nn(nn));
EXPECT_EQ(hash_nn(snn1), hash_nn(snn2)); EXPECT_TRUE(hash_nn(snn1) == hash_nn(snn2));
EXPECT_EQ(hash_snn(snn1), hash_snn(nn)); EXPECT_TRUE(hash_snn(snn1) == hash_snn(nn));
} }
#ifdef CONFIRM_COMPILATION_ERRORS #ifdef CONFIRM_COMPILATION_ERRORS
@ -151,7 +151,7 @@ TEST(strict_notnull_tests, TestStrictNotNullConstructorTypeDeduction)
helper(strict_not_null{&i}); helper(strict_not_null{&i});
helper_const(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(strict_not_null{p});
helper_const(strict_not_null{p}); helper_const(strict_not_null{p});
EXPECT_EQ(*x, 42); EXPECT_TRUE(*x == 42);
} }
{ {

View File

@ -159,19 +159,21 @@ TEST(strided_span_tests, strided_span_constructors)
strided_span<int, 1> sav1{arr, {{9}, {1}}}; // T -> T strided_span<int, 1> sav1{arr, {{9}, {1}}}; // T -> T
EXPECT_TRUE(sav1.bounds().index_bounds() == multi_span_index<1>{9}); EXPECT_TRUE(sav1.bounds().index_bounds() == multi_span_index<1>{9});
EXPECT_TRUE(sav1.bounds().stride() == 1); 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<const int, 1> sav2{carr, {{4}, {2}}}; // const T -> const T strided_span<const int, 1> sav2{carr, {{4}, {2}}}; // const T -> const T
EXPECT_TRUE(sav2.bounds().index_bounds() == multi_span_index<1>{4}); EXPECT_TRUE(sav2.bounds().index_bounds() == multi_span_index<1>{4});
EXPECT_TRUE(sav2.bounds().strides() == multi_span_index<1>{2}); 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<int, 2> sav3{arr, {{2, 2}, {6, 2}}}; // T -> const T strided_span<int, 2> 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().index_bounds() == multi_span_index<2>{2, 2}));
EXPECT_TRUE((sav3.bounds().strides() == multi_span_index<2>{6, 2})); EXPECT_TRUE((sav3.bounds().strides() == multi_span_index<2>{6, 2}));
EXPECT_EQ((sav3[{0, 0}]), 1); EXPECT_TRUE((sav3[{0, 0}]) == 1);
EXPECT_EQ((sav3[{0, 1}]), 3); EXPECT_TRUE((sav3[{0, 1}]) == 3);
EXPECT_EQ((sav3[{1, 0}]), 7); EXPECT_TRUE((sav3[{1, 0}]) == 7);
} }
// EXPECT_TRUE multi_span constructor // EXPECT_TRUE multi_span constructor
@ -310,8 +312,8 @@ TEST(strided_span_tests, strided_span_constructors)
strided_span<const int, 2> sav2{src2}; strided_span<const int, 2> sav2{src2};
EXPECT_TRUE((sav2.bounds().index_bounds() == multi_span_index<2>{3, 2})); EXPECT_TRUE((sav2.bounds().index_bounds() == multi_span_index<2>{3, 2}));
EXPECT_TRUE((sav2.bounds().strides() == multi_span_index<2>{2, 1})); EXPECT_TRUE((sav2.bounds().strides() == multi_span_index<2>{2, 1}));
EXPECT_EQ((sav2[{0, 0}]), 1); EXPECT_TRUE((sav2[{0, 0}]) == 1);
EXPECT_EQ((sav2[{2, 0}]), 5); EXPECT_TRUE((sav2[{2, 0}]) == 5);
} }
// EXPECT_TRUE const-casting assignment operator // EXPECT_TRUE const-casting assignment operator

File diff suppressed because it is too large Load Diff

View File

@ -57,9 +57,9 @@ TEST(utils_tests, finally_lambda)
int i = 0; int i = 0;
{ {
auto _ = finally([&]() { f(i); }); 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) TEST(utils_tests, finally_lambda_move)
@ -69,16 +69,16 @@ TEST(utils_tests, finally_lambda_move)
auto _1 = finally([&]() { f(i); }); auto _1 = finally([&]() { f(i); });
{ {
auto _2 = std::move(_1); 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); 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) TEST(utils_tests, finally_function_with_bind)
@ -86,9 +86,9 @@ TEST(utils_tests, finally_function_with_bind)
int i = 0; int i = 0;
{ {
auto _ = finally(std::bind(&f, std::ref(i))); 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) TEST(utils_tests, finally_function_ptr)
@ -96,27 +96,27 @@ TEST(utils_tests, finally_function_ptr)
j = 0; j = 0;
{ {
auto _ = finally(&g); auto _ = finally(&g);
EXPECT_EQ(j, 0); EXPECT_TRUE(j == 0);
} }
EXPECT_EQ(j, 1); EXPECT_TRUE(j == 1);
} }
TEST(utils_tests, narrow_cast) TEST(utils_tests, narrow_cast)
{ {
int n = 120; int n = 120;
char c = narrow_cast<char>(n); char c = narrow_cast<char>(n);
EXPECT_EQ(c, 120); EXPECT_TRUE(c == 120);
n = 300; n = 300;
unsigned char uc = narrow_cast<unsigned char>(n); unsigned char uc = narrow_cast<unsigned char>(n);
EXPECT_EQ(uc, 44); EXPECT_TRUE(uc == 44);
} }
TEST(utils_tests, narrow) TEST(utils_tests, narrow)
{ {
int n = 120; int n = 120;
const char c = narrow<char>(n); const char c = narrow<char>(n);
EXPECT_EQ(c, 120); EXPECT_TRUE(c == 120);
n = 300; n = 300;
EXPECT_DEATH(narrow<char>(n), ".*"); EXPECT_DEATH(narrow<char>(n), ".*");