Commit d8ac1685 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[1313] Comments corrected, fixed tests for readUint32, writeUint32

parent a0cf3955
......@@ -62,7 +62,7 @@ writeUint16(uint16_t value, void* buffer) {
/// \brief Read Unsigned 32-Bit Integer from Buffer
///
/// \param buffer Data buffer at least two bytes long of which the first two
/// \param buffer Data buffer at least four bytes long of which the first four
/// bytes are assumed to represent a 32-bit integer in network-byte
/// order.
///
......@@ -82,7 +82,7 @@ readUint32(const uint8_t* buffer) {
/// \brief Write Unisgned 32-Bit Integer to Buffer
///
/// \param value 32-bit value to convert
/// \param buffer Data buffer at least two bytes long into which the 16-bit
/// \param buffer Data buffer at least four bytes long into which the 32-bit
/// value is written in network-byte order.
///
/// \return pointer to the next byte after stored value
......
......@@ -88,12 +88,12 @@ TEST(asioutil, readUint32) {
// make sure that we can read data, regardless of
// the memory alignment. That' why we need to repeat
// it 4 times.
for (int offset=0; offset<4; offset++) {
for (int i=0; i< sizeof(test32); i++) {
for (int offset=0; offset < 4; offset++) {
for (int i=0; i< sizeof(test32)/sizeof(uint32_t); i++) {
uint32_t tmp = htonl(test32[i]);
memcpy(&data[offset], &tmp, sizeof(uint32_t) );
memcpy(&data[offset], &tmp, sizeof(uint32_t));
EXPECT_EQ( test32[i], readUint32(&data[offset]) );
EXPECT_EQ(test32[i], readUint32(&data[offset]));
}
}
}
......@@ -105,15 +105,15 @@ TEST(asioutil, writeUint32) {
// make sure that we can write data, regardless of
// the memory alignment. That's why we need to repeat
// it 4 times.
for (int offset=0; offset<4; offset++) {
for (int i=0; i< sizeof(test32); i++) {
for (int offset=0; offset < 4; offset++) {
for (int i=0; i< sizeof(test32)/sizeof(uint32_t); i++) {
uint8_t* ptr = writeUint32(test32[i], &data[offset]);
EXPECT_EQ( &data[offset]+sizeof(uint32_t), ptr );
EXPECT_EQ(&data[offset]+sizeof(uint32_t), ptr);
uint32_t tmp = htonl(test32[i]);
EXPECT_FALSE( memcmp(&tmp, &data[offset], sizeof(uint32_t) ) );
EXPECT_EQ(0, memcmp(&tmp, &data[offset], sizeof(uint32_t)));
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment