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. --- ByteBuffer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ByteBuffer.cpp') diff --git a/ByteBuffer.cpp b/ByteBuffer.cpp index c5f7905..07672ec 100644 --- a/ByteBuffer.cpp +++ b/ByteBuffer.cpp @@ -41,12 +41,12 @@ uint8_t ByteBuffer::get8(size_t index) { } uint8_t ByteBuffer::get8() { - assertCanAccessRelative(1); + assertCanAccessRelative(0); return *ptr++; } uint16_t ByteBuffer::get16le() { - assertCanAccessRelative(1); + assertCanAccessRelative(0); uint16_t value; value = *ptr++; value |= ((uint16_t) *ptr++) << 8; @@ -82,12 +82,12 @@ void ByteBuffer::checkAndUpdateEnd(size_t newBytes) { } void ByteBuffer::assertCanAccessRelative(size_t diff) const { - assertCanAccessIndex(ptr + diff - 1); + assertCanAccessIndex(ptr + diff); } void ByteBuffer::assertCanAccessIndex(uint8_t *p) const { if (p >= end || p < zero) { - throw ByteBufferException(string("Out of bounds! size=") + to_string(getSize())); + throw ByteBufferException(string("Out of bounds! size=") + to_string(getSize()) + ", index=" + to_string(p - zero)); } } -- cgit v1.2.3