aboutsummaryrefslogtreecommitdiff
path: root/orc-rt/unittests/SPSWrapperFunctionTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'orc-rt/unittests/SPSWrapperFunctionTest.cpp')
-rw-r--r--orc-rt/unittests/SPSWrapperFunctionTest.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/orc-rt/unittests/SPSWrapperFunctionTest.cpp b/orc-rt/unittests/SPSWrapperFunctionTest.cpp
index e010e2a..7f88ce0 100644
--- a/orc-rt/unittests/SPSWrapperFunctionTest.cpp
+++ b/orc-rt/unittests/SPSWrapperFunctionTest.cpp
@@ -82,7 +82,7 @@ static void void_noop_sps_wrapper(orc_rt_SessionRef Session, void *CallCtx,
[](move_only_function<void()> Return) { Return(); });
}
-TEST(SPSWrapperFunctionUtilsTest, TestVoidNoop) {
+TEST(SPSWrapperFunctionUtilsTest, VoidNoop) {
bool Ran = false;
SPSWrapperFunction<void()>::call(DirectCaller(nullptr, void_noop_sps_wrapper),
[&](Error Err) {
@@ -102,7 +102,7 @@ static void add_via_lambda_sps_wrapper(orc_rt_SessionRef Session, void *CallCtx,
});
}
-TEST(SPSWrapperFunctionUtilsTest, TestBinaryOpViaLambda) {
+TEST(SPSWrapperFunctionUtilsTest, BinaryOpViaLambda) {
int32_t Result = 0;
SPSWrapperFunction<int32_t(int32_t, int32_t)>::call(
DirectCaller(nullptr, add_via_lambda_sps_wrapper),
@@ -123,7 +123,7 @@ add_via_function_sps_wrapper(orc_rt_SessionRef Session, void *CallCtx,
Session, CallCtx, Return, ArgBytes, add_via_function);
}
-TEST(SPSWrapperFunctionUtilsTest, TestBinaryOpViaFunction) {
+TEST(SPSWrapperFunctionUtilsTest, BinaryOpViaFunction) {
int32_t Result = 0;
SPSWrapperFunction<int32_t(int32_t, int32_t)>::call(
DirectCaller(nullptr, add_via_function_sps_wrapper),
@@ -139,7 +139,7 @@ add_via_function_pointer_sps_wrapper(orc_rt_SessionRef Session, void *CallCtx,
Session, CallCtx, Return, ArgBytes, &add_via_function);
}
-TEST(SPSWrapperFunctionUtilsTest, TestBinaryOpViaFunctionPointer) {
+TEST(SPSWrapperFunctionUtilsTest, BinaryOpViaFunctionPointer) {
int32_t Result = 0;
SPSWrapperFunction<int32_t(int32_t, int32_t)>::call(
DirectCaller(nullptr, add_via_function_pointer_sps_wrapper),
@@ -161,7 +161,7 @@ static void improbable_feat_sps_wrapper(orc_rt_SessionRef Session,
});
}
-TEST(SPSWrapperFunctionUtilsTest, TestFunctionReturningErrorSuccessCase) {
+TEST(SPSWrapperFunctionUtilsTest, TransparentConversionErrorSuccessCase) {
bool DidRun = false;
SPSWrapperFunction<SPSError(bool)>::call(
DirectCaller(nullptr, improbable_feat_sps_wrapper),
@@ -174,7 +174,7 @@ TEST(SPSWrapperFunctionUtilsTest, TestFunctionReturningErrorSuccessCase) {
EXPECT_TRUE(DidRun);
}
-TEST(SPSWrapperFunctionUtilsTest, TestFunctionReturningErrorFailureCase) {
+TEST(SPSWrapperFunctionUtilsTest, TransparentConversionErrorFailureCase) {
std::string ErrMsg;
SPSWrapperFunction<SPSError(bool)>::call(
DirectCaller(nullptr, improbable_feat_sps_wrapper),
@@ -197,7 +197,7 @@ static void halve_number_sps_wrapper(orc_rt_SessionRef Session, void *CallCtx,
});
}
-TEST(SPSWrapperFunctionUtilsTest, TestFunctionReturningExpectedSuccessCase) {
+TEST(SPSWrapperFunctionUtilsTest, TransparentConversionExpectedSuccessCase) {
int32_t Result = 0;
SPSWrapperFunction<SPSExpected<int32_t>(int32_t)>::call(
DirectCaller(nullptr, halve_number_sps_wrapper),
@@ -209,7 +209,7 @@ TEST(SPSWrapperFunctionUtilsTest, TestFunctionReturningExpectedSuccessCase) {
EXPECT_EQ(Result, 1);
}
-TEST(SPSWrapperFunctionUtilsTest, TestFunctionReturningExpectedFailureCase) {
+TEST(SPSWrapperFunctionUtilsTest, TransparentConversionExpectedFailureCase) {
std::string ErrMsg;
SPSWrapperFunction<SPSExpected<int32_t>(int32_t)>::call(
DirectCaller(nullptr, halve_number_sps_wrapper),
@@ -221,6 +221,27 @@ TEST(SPSWrapperFunctionUtilsTest, TestFunctionReturningExpectedFailureCase) {
EXPECT_EQ(ErrMsg, "N is not a multiple of 2");
}
+static void
+round_trip_int_pointer_sps_wrapper(orc_rt_SessionRef Session, void *CallCtx,
+ orc_rt_WrapperFunctionReturn Return,
+ orc_rt_WrapperFunctionBuffer ArgBytes) {
+ SPSWrapperFunction<SPSExecutorAddr(SPSExecutorAddr)>::handle(
+ Session, CallCtx, Return, ArgBytes,
+ [](move_only_function<void(int32_t *)> Return, int32_t *P) {
+ Return(P);
+ });
+}
+
+TEST(SPSWrapperFunctionUtilsTest, TransparentSerializationPointers) {
+ int X = 42;
+ int *P = nullptr;
+ SPSWrapperFunction<SPSExecutorAddr(SPSExecutorAddr)>::call(
+ DirectCaller(nullptr, round_trip_int_pointer_sps_wrapper),
+ [&](Expected<int32_t *> R) { P = cantFail(std::move(R)); }, &X);
+
+ EXPECT_EQ(P, &X);
+}
+
template <size_t N> struct SPSOpCounter {};
namespace orc_rt {
@@ -249,7 +270,7 @@ handle_with_reference_types_sps_wrapper(orc_rt_SessionRef Session,
OpCounter<3> &&) { Return(); });
}
-TEST(SPSWrapperFunctionUtilsTest, TestHandlerWithReferences) {
+TEST(SPSWrapperFunctionUtilsTest, HandlerWithReferences) {
// Test that we can handle by-value, by-ref, by-const-ref, and by-rvalue-ref
// arguments, and that we generate the expected number of moves.
OpCounter<0>::reset();