MCPcopy Create free account
hub / github.com/cutechess/cutechess / readText

Method readText

projects/lib/tests/pipereader/tst_pipereader.cpp:81–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void tst_Pipereader::readText()
82{
83 QFETCH(QString, text);
84 QFETCH(int, maxSize);
85 QFETCH(QString, expect);
86 QByteArray bytes = text.toLatin1();
87 char data[1024];
88 qint64 ms = qint64(maxSize);
89
90 QSignalSpy spy(m_reader, SIGNAL(readyRead()));
91 qint64 bytesWritten = write(bytes.constData());
92
93 while (!spy.count())
94 QTest::qWait(50);
95 QVERIFY(m_reader->canReadLine());
96 QVERIFY(m_reader->bytesAvailable() >= bytesWritten);
97 qint64 readBytes = m_reader->readData(data, ms);
98
99 data[readBytes] = 0; // null termination needed for comparison
100 if (expect.isEmpty())
101 {
102 bytes.truncate(ms);
103 QVERIFY(data == bytes);
104 }
105 else
106 {
107 QVERIFY(data == expect);
108 }
109}
110
111
112QTEST_MAIN(tst_Pipereader)

Callers

nothing calls this directly

Calls 5

countMethod · 0.45
canReadLineMethod · 0.45
bytesAvailableMethod · 0.45
readDataMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected