aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ByteBufferTest.cpp34
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);
}
+*/