Skip to content

Commit

Permalink
#48: fix bug where view hooks test wasn't resetting
Browse files Browse the repository at this point in the history
  • Loading branch information
nmm0 committed Jun 8, 2023
1 parent f21d12f commit 5e719fb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/TestDynamicViewHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,30 +193,40 @@ TYPED_TEST( TestDynamicViewHooks, TestDynamicViewHooksMoveAssign )

KokkosResilience::DynamicViewHooks::move_assignment_set.set_callback(
[&holder](const KokkosResilience::ViewHolder &vh) mutable {
// In both cases here, holder is uninitialized
EXPECT_EQ(holder.data(), nullptr);
EXPECT_NE(vh.data(), nullptr);
holder = vh;
});

KokkosResilience::DynamicViewHooks::move_assignment_set
.set_const_callback(
[&const_holder](
const KokkosResilience::ConstViewHolder &vh) mutable {
// In both cases here, const_holder is uninitialized
EXPECT_EQ(const_holder.data(), nullptr);
EXPECT_NE(vh.data(), nullptr);
const_holder = vh;
});

test_view_type testa("testa", 10, 10);
void *cmp = testa.data();
test_view_type testb;

const_test_view_type testa_const(
testa); // Won't trigger the callback since this is not a copy
// constructor call

// Trigger the non-const move assign callback
testb = std::move(testa);
EXPECT_EQ(cmp, holder.data());
EXPECT_EQ(const_holder.data(), nullptr);
const_test_view_type testa_const(
testa); // Won't trigger the callback since this is not a copy
// constructor call

const_test_view_type testb_const;

// Trigger the const move assign callback
testb_const = std::move(testa_const);
EXPECT_EQ(cmp, const_holder.data());

KokkosResilience::DynamicViewHooks::reset();
}

0 comments on commit 5e719fb

Please sign in to comment.