kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
test_properties.cpp
Go to the documentation of this file.
1
#include "gtest/gtest.h"
2
3
#include "
kokkos-execution/impl/label.hpp
"
4
#include "
kokkos-execution/impl/properties.hpp
"
5
6
#include "
tests/utils/properties.hpp
"
7
18
19
namespace
Tests::Impl
{
20
22
consteval
bool
test_has_property
() {
23
static_assert
(
Kokkos::Execution::Impl::has_property
<
24
Tests::Utils::LabeledData<std::string>
,
25
Kokkos::Execution::Impl::Label<std::string>
26
>());
27
static_assert
(
28
Kokkos::Execution::Impl::has_property<Tests::Utils::LabeledData<std::string>
,
Kokkos::Execution::Impl::Label
>());
29
static_assert
(!
Kokkos::Execution::Impl::has_property<Tests::Utils::LabeledData<std::string>
, Kokkos::ChunkSize>());
30
31
static_assert
(
32
!
Kokkos::Execution::Impl::has_property<Tests::Utils::MyPropA, Kokkos::Execution::Impl::Label<std::string>
>());
33
static_assert
(!
Kokkos::Execution::Impl::has_property
<
34
Tests::Utils::MyPropA
,
35
Kokkos::Execution::Impl::Label<std::string_view>
36
>());
37
38
static_assert
(
Kokkos::Execution::Impl::has_property
<
39
Tests::Utils::MultiPropData<std::string>
,
40
Kokkos::Execution::Impl::Label<std::string>
41
>());
42
static_assert
(
Kokkos::Execution::Impl::has_property
<
43
Tests::Utils::MultiPropData<std::string_view>
,
44
Kokkos::Execution::Impl::Label<std::string_view>
45
>());
46
static_assert
(
47
Kokkos::Execution::Impl::has_property<Tests::Utils::MultiPropData<std::string>
,
Tests::Utils::MyPropA
>());
48
static_assert
(
49
Kokkos::Execution::Impl::has_property<Tests::Utils::MultiPropData<std::string>
,
Tests::Utils::MyPropB
>());
50
51
return
true
;
52
}
53
54
static_assert
(
test_has_property
());
55
57
consteval
bool
test_get_property
() {
58
using
labeled_data_t =
Tests::Utils::LabeledData<std::string_view>
;
59
using
multi_data_t =
Tests::Utils::MultiPropData<std::string_view>
;
60
61
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
62
#define TEST_GET_PROPERTY(_prop_, _data_t_, _value_t_) \
63
static_assert( \
64
std::same_as<decltype(Kokkos::Execution::Impl::get_property<_prop_>(std::declval<_data_t_>())), _value_t_>);
65
67
TEST_GET_PROPERTY
(
Tests::Utils::MyPropA
,
const
multi_data_t&,
const
std::string&)
68
TEST_GET_PROPERTY
(
Tests::Utils::MyPropA
, multi_data_t&, std::string&)
69
TEST_GET_PROPERTY
(
Tests::Utils::MyPropA
, multi_data_t&&, std::string&&)
70
71
72
TEST_GET_PROPERTY
(
Kokkos::Execution::Impl::Label
,
const
labeled_data_t&,
const
std::string_view&)
73
TEST_GET_PROPERTY
(
Kokkos::Execution::Impl::Label
, labeled_data_t&, std::string_view&)
74
TEST_GET_PROPERTY
(
Kokkos::Execution::Impl::Label
, labeled_data_t&&, std::string_view&&)
75
76
#undef TEST_GET_PROPERTY
77
78
constexpr
labeled_data_t data{
"my-nice-label"
};
79
constexpr
auto
value =
Kokkos::Execution::Impl::get_property<Kokkos::Execution::Impl::Label>
(data);
80
static_assert
(value ==
"my-nice-label"
);
81
82
return
true
;
83
}
84
85
static_assert
(
test_get_property
());
86
91
TEST(get_property, label) {
92
ASSERT_EQ(
93
Kokkos::Execution::Impl::get_property<Kokkos::Execution::Impl::Label>
(
94
Tests::Utils::LabeledData<std::string>
{
"my-nice-label"
}),
95
"my-nice-label"
);
96
}
97
98
}
// namespace Tests::Impl
properties.hpp
label.hpp
Kokkos::Execution::Impl::has_property
consteval bool has_property()
Return true when Data derives from the property Property.
Definition
properties.hpp:68
Kokkos::Execution::Impl::get_property
constexpr decltype(auto) get_property(Data &&data) noexcept
Definition
properties.hpp:80
Tests::Impl
Definition
test_compile_time_optional.cpp:16
Tests::Impl::test_has_property
consteval bool test_has_property()
Definition
test_properties.cpp:22
Tests::Impl::test_get_property
consteval bool test_get_property()
Definition
test_properties.cpp:57
Kokkos::Execution::Impl::Label
Label property.
Definition
label.hpp:44
Tests::Utils::LabeledData
Definition
properties.hpp:24
Tests::Utils::MultiPropData
Definition
properties.hpp:30
Tests::Utils::MyPropA
Definition
properties.hpp:15
Tests::Utils::MyPropB
Definition
properties.hpp:19
TEST_GET_PROPERTY
#define TEST_GET_PROPERTY(_prop_, _data_t_, _value_t_)
properties.hpp
tests
impl
test_properties.cpp
Generated on
for kokkos-execution by
1.18.0