From 076fbdda4477b87deb322e43925e010d24d9fa5d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 17 Feb 2015 08:28:14 +0100 Subject: o More tests, more passing tests. --- test/ByteBufferTest.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'test') 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 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); } +*/ -- cgit v1.2.3