Skip to content

Commit

Permalink
qmc-example: Fix QStringBuilder-related issues; more readable QMC_CHECK
Browse files Browse the repository at this point in the history
  • Loading branch information
KitsuneRal committed Dec 14, 2018
1 parent 2cbb053 commit 170bc53
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions examples/qmc-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,22 @@ class QMCTest : public QObject

#define QMC_CHECK(description, condition) \
{ \
const bool result = !!(condition); \
Q_ASSERT(running.removeOne(description)); \
(result ? succeeded : failed).push_back(description); \
cout << (description) << (result ? " successul" : " FAILED") << endl; \
if (targetRoom) \
targetRoom->postMessage(origin % ": " % QStringLiteral(description) % \
(result ? QStringLiteral(" successful") : QStringLiteral(" FAILED")), \
result ? MessageEventType::Notice : MessageEventType::Text); \
if (!!(condition)) \
{ \
succeeded.push_back(description); \
cout << (description) << " successful" << endl; \
if (targetRoom) \
targetRoom->postMessage( \
QStringLiteral("%1: %2 successful").arg(origin, description), \
MessageEventType::Notice); \
} else { \
failed.push_back(description); \
cout << (description) << " FAILED" << endl; \
if (targetRoom) \
targetRoom->postPlainText( \
QStringLiteral("%1: %2 FAILED").arg(origin, description)); \
} \
}

QMCTest::QMCTest(Connection* conn, const QString& testRoomName, QString source)
Expand Down Expand Up @@ -92,7 +100,7 @@ void QMCTest::setup(const QString& testRoomName)
c->sync(10000);
else if (targetRoom)
{
targetRoom->postPlainText(origin % ": All tests finished");
targetRoom->postPlainText(origin + ": All tests finished");
connect(targetRoom, &Room::pendingEventMerged, this, &QMCTest::leave);
}
else
Expand Down Expand Up @@ -185,7 +193,8 @@ void QMCTest::sendMessage()
{
running.push_back("Message sending");
cout << "Sending a message" << endl;
auto txnId = targetRoom->postPlainText("Hello, " % origin % " is here");
auto txnId = targetRoom->postPlainText(
QStringLiteral("Hello, %1 is here").arg(origin));
auto& pending = targetRoom->pendingEvents();
if (pending.empty())
{
Expand Down

0 comments on commit 170bc53

Please sign in to comment.