diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-15 11:01:46 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-15 11:01:46 +0100 |
commit | 60d5440dd3514e71b87948ff5ed30ee38445b8a5 (patch) | |
tree | 0d983caed47449c875c5188e604e81da29e1b82c /ByteBuffer.cpp | |
parent | 041bbe24b39190ac0b624b2709fc38dea17ad0a7 (diff) | |
download | ble-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.cpp | 4 |
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()); |