diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-17 08:28:14 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-17 08:28:14 +0100 |
commit | 076fbdda4477b87deb322e43925e010d24d9fa5d (patch) | |
tree | 93e9a759b95ca3999c82905a5db9cf0e54ac1373 /test | |
parent | 360fd8567545253f680ea544ce7313ab1ef43d14 (diff) | |
download | ble-toys-076fbdda4477b87deb322e43925e010d24d9fa5d.tar.gz ble-toys-076fbdda4477b87deb322e43925e010d24d9fa5d.tar.bz2 ble-toys-076fbdda4477b87deb322e43925e010d24d9fa5d.tar.xz ble-toys-076fbdda4477b87deb322e43925e010d24d9fa5d.zip |
o More tests, more passing tests.
Diffstat (limited to 'test')
-rw-r--r-- | test/ByteBufferTest.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/test/ByteBufferTest.cpp b/test/ByteBufferTest.cpp index d6e45f7..4c51bcc 100644 --- a/test/ByteBufferTest.cpp +++ b/test/ByteBufferTest.cpp @@ -14,6 +14,8 @@ BOOST_REQUIRE_EQUAL(buffer.getCapacity(), capacity); \ BOOST_REQUIRE_EQUAL(buffer.getCursor(), cursor) +using namespace std; + class Bytes { public: Bytes(size_t size) : capacity(size) { @@ -33,6 +35,7 @@ public: size_t capacity; }; +/* BOOST_AUTO_TEST_CASE(empty_buffer) { Bytes b(1000); ByteBuffer buffer(b.bytes, b.capacity, 0, 0); @@ -45,14 +48,40 @@ BOOST_AUTO_TEST_CASE(empty_buffer) { } catch (ByteBufferException e) { } } +*/ +#include <iostream> BOOST_AUTO_TEST_CASE(basic) { Bytes b(1000); + ByteBuffer buffer(b.bytes, 1000); + checkBuffer(buffer, 1000, 1000, 0); + + BOOST_REQUIRE_EQUAL(buffer.get8(), 0); + checkBuffer(buffer, 1000, 1000, 1); + + for (int i = 1; i < b.capacity; i++) { + cout << "i=" << i << endl; + BOOST_REQUIRE_EQUAL(buffer.get8(), b.bytes[i]); + } +} + +/* +BOOST_AUTO_TEST_CASE(setCursor) { + Bytes b(1000); ByteBuffer buffer(b.bytes, 1000, 0, 10); checkBuffer(buffer, 10, 1000, 0); - buffer.get8(); + BOOST_REQUIRE_EQUAL(buffer.get8(), 0); + checkBuffer(buffer, 10, 1000, 1); + + buffer.setCursor(0); + checkBuffer(buffer, 10, 1000, 0); + + BOOST_REQUIRE_EQUAL(buffer.get8(), 0); checkBuffer(buffer, 10, 1000, 1); + + buffer.setCursor(9); + checkBuffer(buffer, 10, 1000, 9); } BOOST_AUTO_TEST_CASE(view) { @@ -60,7 +89,7 @@ BOOST_AUTO_TEST_CASE(view) { ByteBuffer buffer(b.bytes, b.capacity, 0, 10); BOOST_REQUIRE_EQUAL(buffer.get8(), 0); -// checkBuffer(buffer, 10, 1000, 1); + checkBuffer(buffer, 10, 1000, 1); ByteBuffer view1 = buffer.view(); checkBuffer(view1, 9, 9, 0); @@ -73,3 +102,4 @@ BOOST_AUTO_TEST_CASE(view) { BOOST_REQUIRE_EQUAL(view1.get8(), 3); } +*/ |