1
- #include < cib/cib.hpp>
1
+ #include < cib/callback.hpp>
2
+
3
+ #include < stdx/tuple.hpp>
2
4
3
5
#include < catch2/catch_test_macros.hpp>
4
6
@@ -9,33 +11,33 @@ template <typename BuilderValue> constexpr static auto build() {
9
11
}
10
12
11
13
template <typename BuilderMeta, typename BuiltCallback>
12
- constexpr static bool built_is_convertable_to_interface (BuiltCallback) {
14
+ constexpr static bool built_is_convertible_to_interface (BuiltCallback) {
13
15
using interface_type = cib::interface_t <BuilderMeta>;
14
16
return std::is_convertible_v<BuiltCallback, interface_type>;
15
17
}
16
18
17
19
struct EmptyCallbackNoArgs {
18
- using meta = cib::callback_meta <>;
19
- constexpr static auto value = cib::builder_t <meta >{};
20
+ using service = callback::service <>;
21
+ constexpr static auto value = cib::builder_t <service >{};
20
22
};
21
23
22
24
TEST_CASE (" empty callback with no args" , " [callback]" ) {
23
25
constexpr auto built_callback = build<EmptyCallbackNoArgs>();
24
26
25
27
SECTION (" can be called without issue" ) { built_callback (); }
26
28
27
- SECTION (" built type is convertable to the interface type" ) {
28
- REQUIRE (built_is_convertable_to_interface <EmptyCallbackNoArgs::meta >(
29
+ SECTION (" built type is convertible to the interface type" ) {
30
+ REQUIRE (built_is_convertible_to_interface <EmptyCallbackNoArgs::service >(
29
31
built_callback));
30
32
}
31
33
}
32
34
33
35
template <int Id> static bool is_callback_invoked = false ;
34
36
35
37
struct CallbackNoArgsWithSingleExtension {
36
- using meta = cib::callback_meta <>;
38
+ using service = callback::service <>;
37
39
constexpr static auto value = []() {
38
- auto const builder = cib::builder_t <meta >{};
40
+ auto const builder = cib::builder_t <service >{};
39
41
return builder.add ([]() { is_callback_invoked<0 > = true ; });
40
42
}();
41
43
};
@@ -50,14 +52,14 @@ TEST_CASE("callback with no args with single extension", "[callback]") {
50
52
REQUIRE (is_callback_invoked<0 >);
51
53
}
52
54
53
- SECTION (" built type is convertable to the interface type" ) {
54
- REQUIRE (built_is_convertable_to_interface <
55
- CallbackNoArgsWithSingleExtension::meta >(built_callback));
55
+ SECTION (" built type is convertible to the interface type" ) {
56
+ REQUIRE (built_is_convertible_to_interface <
57
+ CallbackNoArgsWithSingleExtension::service >(built_callback));
56
58
}
57
59
}
58
60
59
61
struct CallbackNoArgsWithMultipleExtensions {
60
- using meta = cib::callback_meta <>;
62
+ using service = callback::service <>;
61
63
62
64
static void extension_one () { is_callback_invoked<1 > = true ; }
63
65
@@ -66,7 +68,7 @@ struct CallbackNoArgsWithMultipleExtensions {
66
68
};
67
69
68
70
constexpr static auto value = []() {
69
- auto const builder = cib::builder_t <meta >{};
71
+ auto const builder = cib::builder_t <service >{};
70
72
71
73
return builder.add ([]() { is_callback_invoked<0 > = true ; })
72
74
.add (extension_one)
@@ -89,33 +91,33 @@ TEST_CASE("callback with no args with multiple extensions", "[callback]") {
89
91
REQUIRE (is_callback_invoked<2 >);
90
92
}
91
93
92
- SECTION (" built type is convertable to the interface type" ) {
93
- REQUIRE (built_is_convertable_to_interface <
94
- CallbackNoArgsWithMultipleExtensions::meta >(built_callback));
94
+ SECTION (" built type is convertible to the interface type" ) {
95
+ REQUIRE (built_is_convertible_to_interface <
96
+ CallbackNoArgsWithMultipleExtensions::service >(built_callback));
95
97
}
96
98
}
97
99
98
100
struct CallbackWithArgsWithNoExtensions {
99
- using meta = cib::callback_meta <int , bool >;
100
- constexpr static auto value = cib::builder_t <meta >{};
101
+ using service = callback::service <int , bool >;
102
+ constexpr static auto value = cib::builder_t <service >{};
101
103
};
102
104
103
105
TEST_CASE (" callback with args with no extensions" , " [callback]" ) {
104
106
constexpr auto built_callback = build<CallbackWithArgsWithNoExtensions>();
105
107
106
108
SECTION (" can be called" ) { built_callback (42 , true ); }
107
109
108
- SECTION (" built type is convertable to the interface type" ) {
109
- REQUIRE (built_is_convertable_to_interface <
110
- CallbackWithArgsWithNoExtensions::meta >(built_callback));
110
+ SECTION (" built type is convertible to the interface type" ) {
111
+ REQUIRE (built_is_convertible_to_interface <
112
+ CallbackWithArgsWithNoExtensions::service >(built_callback));
111
113
}
112
114
}
113
115
114
116
template <int Id, typename ... ArgTypes>
115
117
static stdx::tuple<ArgTypes...> callback_args{};
116
118
117
119
struct CallbackWithArgsWithMultipleExtensions {
118
- using meta = cib::callback_meta <int , bool >;
120
+ using service = callback::service <int , bool >;
119
121
120
122
static void extension_one (int a, bool b) {
121
123
is_callback_invoked<1 > = true ;
@@ -128,7 +130,7 @@ struct CallbackWithArgsWithMultipleExtensions {
128
130
};
129
131
130
132
constexpr static auto value = []() {
131
- auto const builder = cib::builder_t <meta >{};
133
+ auto const builder = cib::builder_t <service >{};
132
134
133
135
return builder
134
136
.add ([](int a, bool b) {
@@ -168,8 +170,9 @@ TEST_CASE("callback with args with multiple extensions", "[callback]") {
168
170
REQUIRE (get<1 >(callback_args<2 , int , bool >) == false );
169
171
}
170
172
171
- SECTION (" built type is convertable to the interface type" ) {
172
- REQUIRE (built_is_convertable_to_interface<
173
- CallbackWithArgsWithMultipleExtensions::meta>(built_callback));
173
+ SECTION (" built type is convertible to the interface type" ) {
174
+ REQUIRE (built_is_convertible_to_interface<
175
+ CallbackWithArgsWithMultipleExtensions::service>(
176
+ built_callback));
174
177
}
175
178
}
0 commit comments