podofo09/podofo-0.9.8-upstream-fix_declaration_of_operator.patch

40 lines
1.2 KiB
Diff

From d0e9f5d503b0cb79516ec9bff989f3d7d625b678 Mon Sep 17 00:00:00 2001
From: Pino Toscano <toscano.pino@tiscali.it>
Date: Sun, 14 Aug 2022 08:27:13 +0200
Subject: [PATCH] Fix declaration of operator<< for PoDoFo::PdfString
Since PdfString is in the PoDoFo namespace, the operator<< for it must
be in the same namespace as well, otherwise it is not found. In
particular, operator<<(std::ostream&) is needed by cppunit as a way to
get the string representation of an arbitrary type, when using
CPPUNIT_ASSERT_EQUAL() on instances of it.
This used to work with GCC until 11 because of a buggy behaviour.
GCC 12 fixed it [1], causing this test to fail to build with it.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51577
---
test/unit/StringTest.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/test/unit/StringTest.cpp b/test/unit/StringTest.cpp
index a7841f78..b52b7880 100644
--- a/test/unit/StringTest.cpp
+++ b/test/unit/StringTest.cpp
@@ -29,11 +29,15 @@ using namespace PoDoFo;
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( StringTest );
+namespace PoDoFo {
+
inline std::ostream& operator<<(std::ostream& o, const PdfString& s)
{
return o << s.GetStringUtf8();
}
+}
+
void StringTest::setUp()
{
}