diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-05-27 12:01:50 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-05-27 13:04:43 +0000 |
commit | 7be49c9c1c14375b9ce8595b54766220c3bc1b25 (patch) | |
tree | 0c48f43fcf481514021cf715beb360cecd200da9 | |
parent | 4712765493e6f222d780d4230db32442dd74fd40 (diff) |
Unit test for new QBluetoothHostInfo comparison operators
Change-Id: I40ac86ccf94e8575220e6094dfec0d5537eba3a1
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
-rw-r--r-- | tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp b/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp index 6b86ee10..b55d3abe 100644 --- a/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp +++ b/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp @@ -59,6 +59,9 @@ private slots: void tst_construction(); void tst_copy(); + + void tst_compare_data(); + void tst_compare(); }; tst_QBluetoothHostInfo::tst_QBluetoothHostInfo() @@ -181,6 +184,61 @@ void tst_QBluetoothHostInfo::tst_copy() QCOMPARE(assignOperator.address(), original.address()); } +void tst_QBluetoothHostInfo::tst_compare_data() +{ + QTest::addColumn<QString>("btAddress1"); + QTest::addColumn<QString>("name1"); + QTest::addColumn<QString>("btAddress2"); + QTest::addColumn<QString>("name2"); + QTest::addColumn<bool>("sameHostInfo"); + + QTest::newRow("11:22:33:44:55:66 - same") << QString("11:22:33:44:55:66") << QString("same") + << QString("11:22:33:44:55:66") << QString("same") + << true; + QTest::newRow("11:22:33:44:55:66 - address") << QString("11:22:33:44:55:66") << QString("same") + << QString("11:22:33:44:55:77") << QString("same") + << false; + QTest::newRow("11:22:33:44:55:66 - name") << QString("11:22:33:44:55:66") << QString("same") + << QString("11:22:33:44:55:66") << QString("different") + << false; + QTest::newRow("11:22:33:44:55:66 - name/address") << QString("11:22:33:44:55:66") << QString("same") + << QString("11:22:33:44:55:77") << QString("different") + << false; + QTest::newRow("empty") << QString() << QString() << QString() << QString() << true; + QTest::newRow("empty left") << QString() << QString() + << QString("11:22:33:44:55:66") << QString("same") << false; + QTest::newRow("empty right") << QString("11:22:33:44:55:66") << QString("same") + << QString() << QString() << false; + QTest::newRow("00:00:00:00:00:00") << QString("00:00:00:00:00:00") << QString("foobar1") + << QString("") << QString("foobar1") << true; + QTest::newRow("00:00:00:00:00:00") << QString("00:00:00:00:00:00") << QString("foobar1") + << QString("") << QString("foobar2") << false; + QTest::newRow("00:00:00:00:00:00") << QString("00:00:00:00:00:00") << QString("") + << QString("") << QString("") << true; +} + +void tst_QBluetoothHostInfo::tst_compare() +{ + QFETCH(QString, btAddress1); + QFETCH(QString, name1); + QFETCH(QString, btAddress2); + QFETCH(QString, name2); + QFETCH(bool, sameHostInfo); + + QVERIFY(QBluetoothHostInfo() == QBluetoothHostInfo()); + + QBluetoothHostInfo info1; + info1.setAddress(QBluetoothAddress(btAddress1)); + info1.setName(name1); + + QBluetoothHostInfo info2; + info2.setAddress(QBluetoothAddress(btAddress2)); + info2.setName(name2); + + QCOMPARE(info1 == info2, sameHostInfo); + QCOMPARE(info1 != info2, !sameHostInfo); +} + QTEST_MAIN(tst_QBluetoothHostInfo) #include "tst_qbluetoothhostinfo.moc" |