diff --git a/test/src/test_server_rpc_17.cpp b/test/src/test_server_rpc_17.cpp index d0b19208..094d2e52 100644 --- a/test/src/test_server_rpc_17.cpp +++ b/test/src/test_server_rpc_17.cpp @@ -518,7 +518,7 @@ TEST_CASE_FIXTURE(ServerRPCTest, "Unary ServerRPC with pro test::ArenaRequestMessageFactory& factory) { CHECK_EQ(42, request.integer()); - CHECK_EQ(&factory.arena, request.GetArena()); + CHECK(test::has_arena(request, factory.arena)); rpc.finish({}, grpc::Status::OK, yield); CHECK_FALSE(factory.is_destroy_invoked); }}, @@ -716,7 +716,7 @@ TEST_CASE_FIXTURE(ServerRPCTest, "Unary ServerRPCPtr with { CHECK_EQ(42, request.integer()); CHECK_EQ(&ptr.request(), &request); - CHECK_EQ(&factory.arena, request.GetArena()); + CHECK(test::has_arena(request, factory.arena)); auto& rpc = *ptr; rpc.finish({}, grpc::Status::OK, [ptr = std::move(ptr)](bool ok) diff --git a/test/src/test_unifex_20.cpp b/test/src/test_unifex_20.cpp index 28e87767..a5708a6d 100644 --- a/test/src/test_unifex_20.cpp +++ b/test/src/test_unifex_20.cpp @@ -18,6 +18,7 @@ #include "utils/doctest.hpp" #include "utils/exception.hpp" #include "utils/execution_test.hpp" +#include "utils/protobuf.hpp" #include "utils/requestMessageFactory.hpp" #include "utils/server_rpc.hpp" @@ -161,7 +162,7 @@ TEST_CASE_FIXTURE(test::ExecutionRpcHandlerTest, "unifex rpc_handler unary with [&](test::UnaryServerRPC& rpc, auto& request, test::ArenaRequestMessageFactory& factory) { CHECK_EQ(42, request.integer()); - CHECK_EQ(&factory.arena, request.GetArena()); + CHECK(test::has_arena(request, factory.arena)); return handle_unary_request_sender(rpc, request); }}); run(make_client_unary_request_sender(test::five_seconds_from_now(), diff --git a/test/utils/utils/protobuf.hpp b/test/utils/utils/protobuf.hpp index 91cb7f2f..6b1023c5 100644 --- a/test/utils/utils/protobuf.hpp +++ b/test/utils/utils/protobuf.hpp @@ -16,6 +16,8 @@ #define AGRPC_UTILS_PROTOBUF_HPP #include +#include +#include #include #include #include @@ -40,6 +42,15 @@ grpc::ByteBuffer message_to_grpc_buffer(const Message& message) CHECK_MESSAGE(status.ok(), status.error_message()); return buffer; } + +inline bool has_arena(const google::protobuf::MessageLite& message, const google::protobuf::Arena& arena) +{ +#if GOOGLE_PROTOBUF_VERSION < 4000000 + return true; +#else + return message.GetArena() == &arena; +#endif +} } #endif // AGRPC_UTILS_PROTOBUF_HPP