GH-47659: [C++] Fix Arrow Flight Testing's unresolved external symbol error (#47660)
### Rationale for this change
Fixes issue at https://github.com/apache/arrow/issues/47659
### What changes are included in this PR?
Include add gmock as a shared private link library to `arrow_flight_testing`
### Are these changes tested?
Build for `arrow_flight_testing` succeeds on my Windows environment
### Are there any user-facing changes?
No
* GitHub Issue: #47659
Authored-by: Alina (Xi) Li <alina.li@improving.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt
index d6edbce..359f6d3 100644
--- a/cpp/src/arrow/flight/CMakeLists.txt
+++ b/cpp/src/arrow/flight/CMakeLists.txt
@@ -284,7 +284,9 @@
ArrowTesting::arrow_testing_static)
endif()
list(APPEND ARROW_FLIGHT_TESTING_SHARED_LINK_LIBS ${ARROW_FLIGHT_TEST_INTERFACE_LIBS})
+ list(APPEND ARROW_FLIGHT_TESTING_SHARED_LINK_LIBS ${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TESTING_STATIC_LINK_LIBS ${ARROW_FLIGHT_TEST_INTERFACE_LIBS})
+ list(APPEND ARROW_FLIGHT_TESTING_STATIC_LINK_LIBS ${ARROW_GTEST_GMOCK})
add_arrow_lib(arrow_flight_testing
CMAKE_PACKAGE_NAME
ArrowFlightTesting
diff --git a/cpp/src/arrow/flight/test_util.cc b/cpp/src/arrow/flight/test_util.cc
index e0b73eb..46c8f4c 100644
--- a/cpp/src/arrow/flight/test_util.cc
+++ b/cpp/src/arrow/flight/test_util.cc
@@ -25,6 +25,7 @@
// We need Windows fixes before including Boost
#include "arrow/util/windows_compatibility.h"
+#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "arrow/array.h"
@@ -105,6 +106,20 @@
return payload;
}
+void AssertEqual(const FlightInfo& expected, const FlightInfo& actual) {
+ ipc::DictionaryMemo expected_memo;
+ ipc::DictionaryMemo actual_memo;
+ ASSERT_OK_AND_ASSIGN(auto ex_schema, expected.GetSchema(&expected_memo));
+ ASSERT_OK_AND_ASSIGN(auto actual_schema, actual.GetSchema(&actual_memo));
+
+ AssertSchemaEqual(*ex_schema, *actual_schema);
+ ASSERT_EQ(expected.total_records(), actual.total_records());
+ ASSERT_EQ(expected.total_bytes(), actual.total_bytes());
+
+ ASSERT_EQ(expected.descriptor(), actual.descriptor());
+ ASSERT_THAT(actual.endpoints(), ::testing::ContainerEq(expected.endpoints()));
+}
+
std::shared_ptr<Schema> ExampleIntSchema() {
auto f0 = field("f0", int8());
auto f1 = field("f1", uint8());
diff --git a/cpp/src/arrow/flight/test_util.h b/cpp/src/arrow/flight/test_util.h
index fd0f3c8..59eb9c0 100644
--- a/cpp/src/arrow/flight/test_util.h
+++ b/cpp/src/arrow/flight/test_util.h
@@ -17,7 +17,6 @@
#pragma once
-#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <cstdint>
@@ -42,20 +41,8 @@
// ----------------------------------------------------------------------
// Helpers to compare values for equality
-
-inline void AssertEqual(const FlightInfo& expected, const FlightInfo& actual) {
- ipc::DictionaryMemo expected_memo;
- ipc::DictionaryMemo actual_memo;
- ASSERT_OK_AND_ASSIGN(auto ex_schema, expected.GetSchema(&expected_memo));
- ASSERT_OK_AND_ASSIGN(auto actual_schema, actual.GetSchema(&actual_memo));
-
- AssertSchemaEqual(*ex_schema, *actual_schema);
- ASSERT_EQ(expected.total_records(), actual.total_records());
- ASSERT_EQ(expected.total_bytes(), actual.total_bytes());
-
- ASSERT_EQ(expected.descriptor(), actual.descriptor());
- ASSERT_THAT(actual.endpoints(), ::testing::ContainerEq(expected.endpoints()));
-}
+ARROW_FLIGHT_EXPORT
+void AssertEqual(const FlightInfo& expected, const FlightInfo& actual);
// ----------------------------------------------------------------------
// Fixture to use for running test servers