kokkos-utils 0.0.1
 
Loading...
Searching...
No Matches
test_type_list.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2
4
14
16{
17
18using type_list_t = Kokkos::Impl::type_list<char, short, int>;
19
21TEST(impl, type_list_size_v)
22{
24
25 using type_list_empty_t = Kokkos::Impl::type_list<>;
26 static_assert(type_list_size_v<type_list_empty_t> == 0);
27
28 static_assert(type_list_size_v<type_list_t> == 3);
29}
30
32TEST(impl, type_list_contains_v)
33{
35
36 static_assert( type_list_contains_v<char, type_list_t>);
37 static_assert( ! type_list_contains_v<double, type_list_t>);
38}
39
41TEST(impl, type_list_at_t)
42{
44
45 static_assert(std::same_as<type_list_at_t<0, type_list_t>, char>);
46 static_assert(std::same_as<type_list_at_t<1, type_list_t>, short>);
47 static_assert(std::same_as<type_list_at_t<2, type_list_t>, int>);
48}
49
51template <typename T>
53{
54 using type = std::vector<T>;
55};
56
58TEST(impl, transform_type_list_t)
59{
61
62 using transformed_type_list_t = transform_type_list_t<VectorOfTransformer, type_list_t>;
63
64 using expt_transformed_type_list_t = Kokkos::Impl::type_list<std::vector<char>, std::vector<short>, std::vector<int>>;
65
66 static_assert(std::same_as<transformed_type_list_t, expt_transformed_type_list_t>);
67}
68
70TEST(impl, type_list_to_tuple)
71{
73
74 using expt_tuple_t = std::tuple<char, short, int>;
75
76 static_assert(std::same_as<type_list_to_tuple_t<type_list_t>, expt_tuple_t>);
77}
78
80TEST(impl, type_list_index_v)
81{
83
84 static_assert(type_list_index_v<char, type_list_t> == 0);
85 static_assert(type_list_index_v<short, type_list_t> == 1);
86 static_assert(type_list_index_v<int, type_list_t> == 2);
87}
88
90TEST(impl, for_each)
91{
93
94 static_assert([]() {
95 size_t sum_of_sizes = 0;
96
97 for_each<type_list_t>([&] <typename T>() constexpr {
98 sum_of_sizes += sizeof(T);
99 });
100
101 return sum_of_sizes == sizeof(char) + sizeof(short) + sizeof(int);
102 }());
103}
104
105} // namespace Kokkos::utils::tests::impl
constexpr size_t type_list_size_v
Definition type_list.hpp:24
constexpr bool type_list_contains_v
Definition type_list.hpp:36
constexpr void for_each(Callable callable)
Calls the instantiation of the call operator of a callable object for each type in a Kokkos::Impl::ty...
typename TransformTypeList< TransformerType, T >::type transform_type_list_t
Definition type_list.hpp:70
typename TypeListToTuple< T >::type type_list_to_tuple_t
Definition type_list.hpp:85
constexpr size_t type_list_index_v
typename TypeListAt< I, T >::type type_list_at_t
Definition type_list.hpp:55
Kokkos::Impl::type_list< char, short, int > type_list_t
TEST(impl, type_list_size_v)
Helper struct for the test of Kokkos::utils::impl::transform_type_list_t.