aboutsummaryrefslogtreecommitdiff
path: root/test/MacTest.cpp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-12-20 08:35:51 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2018-12-20 08:35:51 +0100
commitffa313e80a27005405334db6491075442f6e1abd (patch)
tree23a48c91cfc0810afe88cc6104d0667516fbd4a9 /test/MacTest.cpp
parentaf416f81b14a3bee682e300b165a6efdb9739d54 (diff)
downloadble-toys-ffa313e80a27005405334db6491075442f6e1abd.tar.gz
ble-toys-ffa313e80a27005405334db6491075442f6e1abd.tar.bz2
ble-toys-ffa313e80a27005405334db6491075442f6e1abd.tar.xz
ble-toys-ffa313e80a27005405334db6491075442f6e1abd.zip
o Using more natural byte ordering in the code. No external effect. o Using global ==, != and < operators instead of in-class operators for better compatibility with STL. ByteBuffer: o Renaming setPosition() to setCursor().
Diffstat (limited to 'test/MacTest.cpp')
-rw-r--r--test/MacTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/MacTest.cpp b/test/MacTest.cpp
new file mode 100644
index 0000000..7af1624
--- /dev/null
+++ b/test/MacTest.cpp
@@ -0,0 +1,30 @@
+#include "ble/Bluetooth.h"
+
+#define BOOST_TEST_MODULE "MacTest"
+
+#include <boost/test/unit_test.hpp>
+
+using trygvis::bluetooth::Mac;
+
+BOOST_AUTO_TEST_CASE(parseMac) {
+ auto mac = Mac::parseMac("11:22:33:44:55:FF");
+ uint8_t b1, b2, b3, b4, b5, b6;
+ mac.copy(b1, b2, b3, b4, b5, b6);
+ BOOST_CHECK_EQUAL(0x11, b1);
+ BOOST_CHECK_EQUAL(0x22, b2);
+ BOOST_CHECK_EQUAL(0x33, b3);
+ BOOST_CHECK_EQUAL(0x44, b4);
+ BOOST_CHECK_EQUAL(0x55, b5);
+ BOOST_CHECK_EQUAL(0xff, b6);
+ BOOST_CHECK_EQUAL("11:22:33:44:55:ff", mac.str());
+}
+
+BOOST_AUTO_TEST_CASE(equal) {
+ Mac a(0x11, 0x22, 0x33, 0x44, 0x55, 0xFF);
+ auto a2 = Mac::parseMac("11:22:33:44:55:FF");
+ BOOST_CHECK_EQUAL(a, a2);
+
+ Mac b(0x11, 0x22, 0x33, 0xff, 0x10, 0x02);
+
+ BOOST_CHECK_LT(a, b);
+}