diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-11-13 10:19:46 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-12-07 14:17:16 +0100 |
commit | a07925576a82e8e6e627d13d22416b05f5bb534b (patch) | |
tree | a9e8f941b6996f55be22b95a69f40575fee749ae /tests/auto/corelib | |
parent | cedf0207d1ebd931fe155ca04abbf3cb0702854a (diff) |
Fix qChecksum test
The test passed mostly by accident so far, as the created QByteArray
was shorter than what the test assumed.
Change-Id: I06858801d83a504eadc73ec2be281c88f8ffad5d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index 90dfcaef25..cc65662e26 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -251,11 +251,11 @@ void tst_QByteArray::qChecksum_data() QTest::addColumn<uint>("checksum"); // Examples from ISO 14443-3 - QTest::newRow("1") << QByteArray("\x00\x00") << 2U << Qt::ChecksumItuV41 << 0x1EA0U; - QTest::newRow("2") << QByteArray("\x12\x34") << 2U << Qt::ChecksumItuV41 << 0xCF26U; - QTest::newRow("3") << QByteArray("\x00\x00\x00") << 3U << Qt::ChecksumIso3309 << 0xC6CCU; - QTest::newRow("4") << QByteArray("\x0F\xAA\xFF") << 3U << Qt::ChecksumIso3309 << 0xD1FCU; - QTest::newRow("5") << QByteArray("\x0A\x12\x34\x56") << 4U << Qt::ChecksumIso3309 << 0xF62CU; + QTest::newRow("1") << QByteArray("\x00\x00", 2) << 2U << Qt::ChecksumItuV41 << 0x1EA0U; + QTest::newRow("2") << QByteArray("\x12\x34", 2) << 2U << Qt::ChecksumItuV41 << 0xCF26U; + QTest::newRow("3") << QByteArray("\x00\x00\x00", 3) << 3U << Qt::ChecksumIso3309 << 0xC6CCU; + QTest::newRow("4") << QByteArray("\x0F\xAA\xFF", 3) << 3U << Qt::ChecksumIso3309 << 0xD1FCU; + QTest::newRow("5") << QByteArray("\x0A\x12\x34\x56", 4) << 4U << Qt::ChecksumIso3309 << 0xF62CU; } void tst_QByteArray::qChecksum() @@ -265,6 +265,7 @@ void tst_QByteArray::qChecksum() QFETCH(Qt::ChecksumType, standard); QFETCH(uint, checksum); + QCOMPARE(data.length(), int(len)); if (standard == Qt::ChecksumIso3309) { QCOMPARE(::qChecksum(data.constData(), len), static_cast<quint16>(checksum)); } |