diff options
author | kuzulis <scapig2@yandex.ru> | 2011-11-19 16:58:44 +0400 |
---|---|---|
committer | kuzulis <kuzulis@kuzulis.localdomain> | 2011-11-19 16:58:44 +0400 |
commit | 7f22362b48c425a50fda9f88b85841c0bf82d4ae (patch) | |
tree | a6455b0b27dce9a9e30beb4c8eb35d97d4a86c11 | |
parent | 4c644617ec463ebd2ddc445b553e504641b629a1 (diff) | |
download | qtserialport-7f22362b48c425a50fda9f88b85841c0bf82d4ae.tar.gz |
/tests/guidevtest: For test "IO test" added function to create randomly
the data array given size. In this case, control characters 11h and 13h
(XON/XOFF) are not added to the array.
-rw-r--r-- | tests/guidevtest/unittestio.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/guidevtest/unittestio.cpp b/tests/guidevtest/unittestio.cpp index b426ae9..2aff9c0 100644 --- a/tests/guidevtest/unittestio.cpp +++ b/tests/guidevtest/unittestio.cpp @@ -78,6 +78,22 @@ static QString split_on_table(const QByteArray &data, int tablewidth) return result; } +static QByteArray random_data_array(int arraysize) +{ + QByteArray result; + while (arraysize--) { + // Here, protection of control characters 11h, 13h + // with software flow control. + char c; + do { + c = qrand(); + } while ((c == 0x11) || (c == 0x13)); + + result.append(c); + } + return result; +} + /* Public methods */ @@ -218,7 +234,7 @@ void UnitTestIO::transaction() "\ndatabits: %2" "\npatity : %3" "\nstopbits: %4" - "\nflow : %5\n")); + "\nflow : %5\n\n")); content = content .arg(QString(sratesarray[m_rateIterator])) @@ -229,7 +245,7 @@ void UnitTestIO::transaction() m_logger->addContent(content); - QByteArray data(TransferBytesCount, qrand()); + QByteArray data = random_data_array(TransferBytesCount); m_bytesWrite = m_srcPort->write(data); content = "w:\n%1\n"; |