| 79 | } |
| 80 | |
| 81 | void 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 | |
| 112 | QTEST_MAIN(tst_Pipereader) |
nothing calls this directly
no test coverage detected