aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/UuidTest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/UuidTest.cpp b/test/UuidTest.cpp
new file mode 100644
index 0000000..b31c121
--- /dev/null
+++ b/test/UuidTest.cpp
@@ -0,0 +1,29 @@
+#include "ble/Bluetooth.h"
+
+#define BOOST_TEST_MODULE "UuidTest"
+
+#include <boost/test/unit_test.hpp>
+
+using namespace std;
+using namespace trygvis::bluetooth;
+
+BOOST_AUTO_TEST_CASE(uuid) {
+ BOOST_CHECK_EQUAL("0001", ShortUuid{0x01}.str());
+ BOOST_CHECK_EQUAL("2a1c", uuids::TemperatureMeasurement.str());
+ BOOST_CHECK_EQUAL("00001809-0000-1000-8000-00805f9b34fb", uuids::HealthTermometerService.toLong().str());
+}
+
+BOOST_AUTO_TEST_CASE(fromString) {
+ auto o = Uuid::fromString("abcd");
+ BOOST_CHECK(!!o);
+ if (o) {
+ BOOST_CHECK_EQUAL(ShortUuid(0xabcd).toLong().str(), o.value().str());
+ }
+
+ o = Uuid::fromString("0xabcd");
+ BOOST_CHECK(!o);
+
+ o = Uuid::fromString("00001809-0000-1000-8000-00805f9b34fb");
+ BOOST_CHECK(!!o);
+ BOOST_CHECK_EQUAL(o.value().str(), uuids::HealthTermometerService.toLong().str());
+}