aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-11-17 22:38:32 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2018-11-17 22:38:32 +0100
commit52450ed3034b0ba058ea2c9f9baa2d5f78df6a94 (patch)
tree97fe35d5d7fe6fe354b2effe8c0ef4836787eb83 /test
parenta167d6e68e634a70af442cd86e43fd9223b1431c (diff)
downloadble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.tar.gz
ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.tar.bz2
ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.tar.xz
ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.zip
apps/ble-bts:
o Adding start of health termometer service tool. apps/ble-read-characteristic: o Sart of new tool. apps/ble-inspect-device o Make adapter configurable. other: o UUID fixes and tests.
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());
+}