aboutsummaryrefslogtreecommitdiff
path: root/ByteBuffer.cpp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-02-15 11:01:46 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-02-15 11:01:46 +0100
commit60d5440dd3514e71b87948ff5ed30ee38445b8a5 (patch)
tree0d983caed47449c875c5188e604e81da29e1b82c /ByteBuffer.cpp
parent041bbe24b39190ac0b624b2709fc38dea17ad0a7 (diff)
downloadble-toys-60d5440dd3514e71b87948ff5ed30ee38445b8a5.tar.gz
ble-toys-60d5440dd3514e71b87948ff5ed30ee38445b8a5.tar.bz2
ble-toys-60d5440dd3514e71b87948ff5ed30ee38445b8a5.tar.xz
ble-toys-60d5440dd3514e71b87948ff5ed30ee38445b8a5.zip
o wip. Test cases!
Diffstat (limited to 'ByteBuffer.cpp')
-rw-r--r--ByteBuffer.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/ByteBuffer.cpp b/ByteBuffer.cpp
index 912e697..f27deeb 100644
--- a/ByteBuffer.cpp
+++ b/ByteBuffer.cpp
@@ -3,11 +3,13 @@
#include <string.h>
#include <sstream>
#include <iomanip>
+#include <cassert>
using namespace std;
ByteBuffer::ByteBuffer(uint8_t *bytes, size_t capacity, size_t size, size_t zero) :
bytes(bytes), capacity(capacity), size(size), cursor(zero), zero(zero) {
+ assert(zero <= size);
}
ByteBuffer &ByteBuffer::add8(uint8_t value) {
@@ -73,7 +75,7 @@ std::string ByteBuffer::toString() const {
stringstream s;
for(size_t i = zero; i < size; i++) {
- s << hex << setfill('0') << setw(2) << bytes[i] << " ";
+ s << hex << setfill('0') << setw(2) << (int) bytes[i] << " ";
}
return string(s.str());