summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-24 17:24:15 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-12 08:22:44 -0700
commitc6b62cbe5c4662984f1a3650e4913fe0e9b9383b (patch)
treee4a0bbf4b4a57ca14ceb43bf66b160e89dc6cf97 /tests
parent0cfd76740b1af1424c39151e1628e1af6480a2d6 (diff)
downloadsubsurface-c6b62cbe5c4662984f1a3650e4913fe0e9b9383b.tar.gz
tests: add test for the BT/BLE address recognition
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/testhelper.cpp26
-rw-r--r--tests/testhelper.h15
3 files changed, 42 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b4bdc6610..04b33b459 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -92,6 +92,7 @@ TEST(TestUnitConversion testunitconversion.cpp)
TEST(TestProfile testprofile.cpp)
TEST(TestGpsCoords testgpscoords.cpp)
TEST(TestParse testparse.cpp)
+TEST(TestHelper testhelper.cpp)
TEST(TestParsePerformance testparseperformance.cpp)
TEST(TestPlan testplan.cpp)
TEST(TestDiveSiteDuplication testdivesiteduplication.cpp)
diff --git a/tests/testhelper.cpp b/tests/testhelper.cpp
new file mode 100644
index 000000000..6d15ad3c4
--- /dev/null
+++ b/tests/testhelper.cpp
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "testhelper.h"
+#include "core/btdiscovery.h"
+
+void TestHelper::initTestCase()
+{
+ /* we need to manually tell that the resource exists, because we are using it as library. */
+ Q_INIT_RESOURCE(subsurface);
+}
+
+void TestHelper::recognizeBtAddress()
+{
+ QCOMPARE(isBluetoothAddress("01:a2:b3:c4:d5:06"), true);
+ QCOMPARE(isBluetoothAddress("LE:01:A2:B3:C4:D5:06"), true);
+ QCOMPARE(isBluetoothAddress("01:A2:b3:04:05"), false);
+ QCOMPARE(isBluetoothAddress("LE:01:02:03:04:05"), false);
+ QCOMPARE(isBluetoothAddress("01:02:03:04:051:67"), false);
+ QCOMPARE(isBluetoothAddress("LE:01:g2:03:04:05"), false);
+ QCOMPARE(isBluetoothAddress("LE:{6e50ff5d-cdd3-4c43-a80a-1ed4c7d2d2a5}"), true);
+ QCOMPARE(isBluetoothAddress("LE:{6e5ff5d-cdd3-4c43-a80a-1ed4c7d2d2a5}"), false);
+ QCOMPARE(isBluetoothAddress("LE:{6e50ff5d-cdda33-4c43-a80a-1ed4c7d2d2a5}"), false);
+ QCOMPARE(isBluetoothAddress("LE:{6e50ff5d-cdd3-4c43-1ed4c7d2d2a5}"), false);
+ QCOMPARE(isBluetoothAddress("LE:{6e50ff5d-cdd3-4c43-ag0a-1ed4c7d2d2a5}"), false);
+}
+
+QTEST_GUILESS_MAIN(TestHelper)
diff --git a/tests/testhelper.h b/tests/testhelper.h
new file mode 100644
index 000000000..e6af513dc
--- /dev/null
+++ b/tests/testhelper.h
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef TESTPARSE_H
+#define TESTPARSE_H
+
+#include <QtTest>
+#include <sqlite3.h>
+
+class TestHelper : public QObject {
+ Q_OBJECT
+private slots:
+ void initTestCase();
+ void recognizeBtAddress();
+};
+
+#endif