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" }
This commit is contained in:
Povilas Kanapickas 2025-03-06 13:08:16 +02:00 committed by GitHub
parent 0d3493e7f6
commit ab97f39ea4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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() << '"';