From ab97f39ea4367a5ba3fb037b8a068b341d99c96f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 6 Mar 2025 13:08:16 +0200 Subject: [PATCH] chore: Fix pretty printing for QString (#101) Previously QString was printed symbol by symbol. E.g.: reader.readWholeFileAfter(3, 1) Which is: { "i", "n", "e", " ", "2", " ", "L", "i", "n", "e", " ", "3" } --- test/DocumentContextReaderTest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/DocumentContextReaderTest.cpp b/test/DocumentContextReaderTest.cpp index 5dbfe02..91aeaba 100644 --- a/test/DocumentContextReaderTest.cpp +++ b/test/DocumentContextReaderTest.cpp @@ -27,6 +27,16 @@ using namespace QodeAssist::Context; using namespace QodeAssist::LLMCore; using namespace QodeAssist::Settings; +QT_BEGIN_NAMESPACE + +// gtest can't pick pretty printer when comparing QString +inline void PrintTo(const QString &value, ::std::ostream *out) +{ + *out << '"' << value.toStdString() << '"'; +} + +QT_END_NAMESPACE + std::ostream &operator<<(std::ostream &out, const QString &value) { out << '"' << value.toStdString() << '"';