blob: 641935f684b9bb75856a5ddd8098e222654a5b5d [file] [log] [blame]
Andrew Geisslerd5838332022-05-27 11:33:10 -05001commit 7f437a6e06d2ec3abd3e2fd1101ab6aab386bc44
2Author: Stanislav Angelovic <stanislav.angelovic@siemens.com>
3Date: Thu Jan 27 13:38:19 2022 +0100
4
5 fix(tests): printer for std::chrono in googletest v1.11.0
6
7diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
8index fbf198c..ec42e55 100644
9--- a/tests/CMakeLists.txt
10+++ b/tests/CMakeLists.txt
11@@ -19,7 +19,7 @@ if (NOT TARGET GTest::gmock)
12 if (NOT TARGET GTest::gmock)
13 include(FetchContent)
14
15- message("Fetching googletest...")
16+ message("Fetching googletest v${GOOGLETEST_VERSION}...")
17 FetchContent_Declare(googletest
18 GIT_REPOSITORY ${GOOGLETEST_GIT_REPO}
19 GIT_TAG release-${GOOGLETEST_VERSION}
20diff --git a/tests/integrationtests/Defs.h b/tests/integrationtests/Defs.h
21index 2f129a4..2bfc7c9 100644
22--- a/tests/integrationtests/Defs.h
23+++ b/tests/integrationtests/Defs.h
24@@ -56,20 +56,18 @@ const bool DEFAULT_BLOCKING_VALUE{true};
25
26 constexpr const double DOUBLE_VALUE{3.24L};
27
28-/** Duration stream operator for human readable gtest value output.
29- *
30- * Note that the conversion to double is lossy if the input type has 64 or more bits.
31- * This is ok for our integration tests because they don't have very
32- * accurate timing requirements.
33- *
34- * @return human readable duration in seconds
35- */
36+}}
37+
38+namespace testing::internal {
39+
40+// Printer for std::chrono::duration types.
41+// This is a workaround, since it's not a good thing to add this to std namespace.
42 template< class Rep, class Period >
43-static std::ostream& operator<<(std::ostream& os, const std::chrono::duration<Rep, Period>& d)
44-{
45+void PrintTo(const ::std::chrono::duration<Rep, Period>& d, ::std::ostream* os) {
46 auto seconds = std::chrono::duration_cast<std::chrono::duration<double>>(d);
47- return os << seconds.count() << " s";
48+ *os << seconds.count() << "s";
49+}
50+
51 }
52-}}
53
54 #endif /* SDBUS_CPP_INTEGRATIONTESTS_DEFS_H_ */