Skip to content

Commit

Permalink
Added back to_Array tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nliber committed May 24, 2024
1 parent aa8ecfb commit bca7a65
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions core/unit_test/TestArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,23 @@ constexpr bool test_array_specialization_kokkos_swap() {

static_assert(test_array_specialization_kokkos_swap());

KOKKOS_FUNCTION constexpr bool test_to_array() {
// copies a string literal
auto a1 = Kokkos::to_Array("foo");
static_assert(a1.size() == 4);

// deduces both element type and length
auto a2 = Kokkos::to_Array({0, 2, 1, 3});
static_assert(std::is_same_v<decltype(a2), Kokkos::Array<int, 4>>);

// deduces length with element type specified
// implicit conversion happens
auto a3 = Kokkos::to_Array<long>({0, 1, 3});
static_assert(std::is_same_v<decltype(a3), Kokkos::Array<long, 3>>);

return true;
}

static_assert(test_to_array());

} // namespace

0 comments on commit bca7a65

Please sign in to comment.