Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Feb 8, 2024
1 parent d02e9c3 commit d1de277
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/tstAttachIndices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

BOOST_AUTO_TEST_SUITE(AttachIndices)

BOOST_AUTO_TEST_CASE(attach_indices)
BOOST_AUTO_TEST_CASE(attach_indices_to_primitives)
{
using ArborX::Details::AccessValues;
using ArborX::Experimental::attach_indices;
Expand All @@ -25,8 +25,15 @@ BOOST_AUTO_TEST_CASE(attach_indices)
auto p_with_indices = attach_indices(p);
AccessValues<decltype(p_with_indices), ArborX::PrimitivesTag> p_values{
p_with_indices};
static_assert(std::is_same_v<decltype(p_values(0).index), unsigned>);
BOOST_TEST(p_values(0).index == 0);
BOOST_TEST(p_values(9).index == 9);
}

BOOST_AUTO_TEST_CASE(attach_indices_to_predicates)
{
using ArborX::Details::AccessValues;
using ArborX::Experimental::attach_indices;

using IntersectsPredicate = decltype(ArborX::intersects(ArborX::Point{}));
Kokkos::View<IntersectsPredicate *, Kokkos::HostSpace> q("Testing::q", 10);
Expand Down
14 changes: 14 additions & 0 deletions test/tstCompileOnlyAccessTraits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ void test_access_traits_compile_only()
std::decay_t<decltype(ArborX::getData(std::declval<predicate>()))>,
long>);

struct CustomIndex
{
char index;
CustomIndex(int i) { index = i; }
};
auto q_with_custom_indices =
ArborX::Experimental::attach_indices<CustomIndex>(q);
check_valid_access_traits(PredicatesTag{}, q_with_custom_indices);
using predicate_custom =
deduce_type_t<decltype(q_with_custom_indices), PredicatesTag>;
static_assert(std::is_same_v<std::decay_t<decltype(ArborX::getData(
std::declval<predicate_custom>()))>,
CustomIndex>);

// Uncomment to see error messages

// check_valid_access_traits(PrimitivesTag{}, NoAccessTraitsSpecialization{});
Expand Down

0 comments on commit d1de277

Please sign in to comment.