@@ -90,20 +90,57 @@ TEST(SPSWrapperFunctionUtilsTest, TestVoidNoop) {
90
90
EXPECT_TRUE (Ran);
91
91
}
92
92
93
- static void add_sps_wrapper (orc_rt_SessionRef Session, void *CallCtx,
94
- orc_rt_WrapperFunctionReturn Return,
95
- orc_rt_WrapperFunctionBuffer ArgBytes) {
93
+ static void add_via_lambda_sps_wrapper (orc_rt_SessionRef Session, void *CallCtx,
94
+ orc_rt_WrapperFunctionReturn Return,
95
+ orc_rt_WrapperFunctionBuffer ArgBytes) {
96
96
SPSWrapperFunction<int32_t (int32_t , int32_t )>::handle (
97
97
Session, CallCtx, Return, ArgBytes,
98
98
[](move_only_function<void (int32_t )> Return, int32_t X, int32_t Y) {
99
99
Return (X + Y);
100
100
});
101
101
}
102
102
103
- TEST (SPSWrapperFunctionUtilsTest, TestAdd ) {
103
+ TEST (SPSWrapperFunctionUtilsTest, TestBinaryOpViaLambda ) {
104
104
int32_t Result = 0 ;
105
105
SPSWrapperFunction<int32_t (int32_t , int32_t )>::call (
106
- DirectCaller (nullptr , add_sps_wrapper),
106
+ DirectCaller (nullptr , add_via_lambda_sps_wrapper),
107
+ [&](Expected<int32_t > R) { Result = cantFail (std::move (R)); }, 41 , 1 );
108
+ EXPECT_EQ (Result, 42 );
109
+ }
110
+
111
+ static void add_via_function (move_only_function<void (int32_t )> Return,
112
+ int32_t X, int32_t Y) {
113
+ Return (X + Y);
114
+ }
115
+
116
+ static void
117
+ add_via_function_sps_wrapper (orc_rt_SessionRef Session, void *CallCtx,
118
+ orc_rt_WrapperFunctionReturn Return,
119
+ orc_rt_WrapperFunctionBuffer ArgBytes) {
120
+ SPSWrapperFunction<int32_t (int32_t , int32_t )>::handle (
121
+ Session, CallCtx, Return, ArgBytes, add_via_function);
122
+ }
123
+
124
+ TEST (SPSWrapperFunctionUtilsTest, TestBinaryOpViaFunction) {
125
+ int32_t Result = 0 ;
126
+ SPSWrapperFunction<int32_t (int32_t , int32_t )>::call (
127
+ DirectCaller (nullptr , add_via_function_sps_wrapper),
128
+ [&](Expected<int32_t > R) { Result = cantFail (std::move (R)); }, 41 , 1 );
129
+ EXPECT_EQ (Result, 42 );
130
+ }
131
+
132
+ static void
133
+ add_via_function_pointer_sps_wrapper (orc_rt_SessionRef Session, void *CallCtx,
134
+ orc_rt_WrapperFunctionReturn Return,
135
+ orc_rt_WrapperFunctionBuffer ArgBytes) {
136
+ SPSWrapperFunction<int32_t (int32_t , int32_t )>::handle (
137
+ Session, CallCtx, Return, ArgBytes, &add_via_function);
138
+ }
139
+
140
+ TEST (SPSWrapperFunctionUtilsTest, TestBinaryOpViaFunctionPointer) {
141
+ int32_t Result = 0 ;
142
+ SPSWrapperFunction<int32_t (int32_t , int32_t )>::call (
143
+ DirectCaller (nullptr , add_via_function_pointer_sps_wrapper),
107
144
[&](Expected<int32_t > R) { Result = cantFail (std::move (R)); }, 41 , 1 );
108
145
EXPECT_EQ (Result, 42 );
109
146
}
0 commit comments