Skip to content

Commit

Permalink
Prefer ASSERT_EQ over ASSERT_TRUE with ==
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed Jan 22, 2023
1 parent 6e73a35 commit 73b4ca8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions core/unit_test/TestStackTrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ void test_stacktrace(bool bTerminate, bool bCustom = true) {
if (bDynamic) {
std::string foutput = sstream.str();
printf("demangled test_f1: %s \n", foutput.c_str());
ASSERT_TRUE(std::string::npos !=
foutput.find("Test::stacktrace_test_f1"));
ASSERT_NE(std::string::npos, foutput.find("Test::stacktrace_test_f1"));
for (auto x : {"stacktrace_test_f0", "stacktrace_test_f2",
"stacktrace_test_f3", "stacktrace_test_f4"}) {
ASSERT_EQ(std::string::npos, foutput.find(x));
Expand Down
4 changes: 2 additions & 2 deletions core/unit_test/TestTeam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ struct TestScratchAlignment {
Kokkos::fence();
int minimal_scratch_allocation_failed = 0;
Kokkos::deep_copy(minimal_scratch_allocation_failed, flag);
ASSERT_TRUE(minimal_scratch_allocation_failed == 0);
ASSERT_EQ(minimal_scratch_allocation_failed, 0);
}

// test alignment of successive allocations
Expand Down Expand Up @@ -1650,7 +1650,7 @@ struct TestScratchAlignment {
Kokkos::fence();
int raw_get_shmem_alignment_failed = 0;
Kokkos::deep_copy(raw_get_shmem_alignment_failed, flag);
ASSERT_TRUE(raw_get_shmem_alignment_failed == 0);
ASSERT_EQ(raw_get_shmem_alignment_failed, 0);
}
};

Expand Down
12 changes: 6 additions & 6 deletions core/unit_test/TestViewSubview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ void test_left_1(bool use_constr) {
for (int i1 = 0; i1 < (int)sx4.extent(1); ++i1)
for (int i2 = 0; i2 < (int)sx4.extent(2); ++i2)
for (int i3 = 0; i3 < (int)sx4.extent(3); ++i3) {
ASSERT_TRUE(&sx4(i0, i1, i2, i3) ==
&x8(0, 0 + i0, 1, 1 + i1, 1, 0 + i2, 2, 2 + i3));
ASSERT_EQ(&sx4(i0, i1, i2, i3),
&x8(0, 0 + i0, 1, 1 + i1, 1, 0 + i2, 2, 2 + i3));
}
}
}
Expand Down Expand Up @@ -546,8 +546,8 @@ void test_left_2() {
for (int i1 = 0; i1 < (int)sx4.extent(1); ++i1)
for (int i2 = 0; i2 < (int)sx4.extent(2); ++i2)
for (int i3 = 0; i3 < (int)sx4.extent(3); ++i3) {
ASSERT_TRUE(&sx4(i0, i1, i2, i3) ==
&x4(1 + i0, 1 + i1, 0 + i2, 2 + i3));
ASSERT_EQ(&sx4(i0, i1, i2, i3),
&x4(1 + i0, 1 + i1, 0 + i2, 2 + i3));
}
}
}
Expand Down Expand Up @@ -756,8 +756,8 @@ void test_right_1(bool use_constr) {
for (int i1 = 0; i1 < (int)sx4.extent(1); ++i1)
for (int i2 = 0; i2 < (int)sx4.extent(2); ++i2)
for (int i3 = 0; i3 < (int)sx4.extent(3); ++i3) {
ASSERT_TRUE(&sx4(i0, i1, i2, i3) ==
&x8(0, 0 + i0, 1, 1 + i1, 1, 0 + i2, 2, 2 + i3));
ASSERT_EQ(&sx4(i0, i1, i2, i3),
&x8(0, 0 + i0, 1, 1 + i1, 1, 0 + i2, 2, 2 + i3));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/unit_test/tools/TestEventCorrectness.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ TEST(kokkosp, test_multiple_default_instances) {
ex1.fence("named_instance_fence_one");
ex2.fence("named_instance_fence_two");
});
ASSERT_TRUE(found_payloads[0].dev_id == found_payloads[1].dev_id);
ASSERT_EQ(found_payloads[0].dev_id, found_payloads[1].dev_id);
});
}

Expand Down Expand Up @@ -716,7 +716,7 @@ TEST(kokkosp, get_events) {
});
for (const auto& ptr : event_vector) {
auto ptr_as_begin = std::dynamic_pointer_cast<BeginParallelForEvent>(ptr);
ASSERT_TRUE(ptr_as_begin == nullptr);
ASSERT_EQ(ptr_as_begin, nullptr);
}
}
} // namespace Test

0 comments on commit 73b4ca8

Please sign in to comment.