diff options
author | Tom Gundersen <teg@jklm.no> | 2014-11-04 19:52:04 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-11-05 16:54:22 +0100 |
commit | 617e79465249e694d697fd78704571b3d00338c8 (patch) | |
tree | 10b6c91f2a508c9982cd218ed92b6a80682e5f21 /src/test | |
parent | 9eec671331adeb3f9a81b390758000364388a042 (diff) |
shared: unaligned - use void* instead of unaligned be16_t*
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-unaligned.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/src/test/test-unaligned.c b/src/test/test-unaligned.c index 52693cd325..1754d06b2d 100644 --- a/src/test/test-unaligned.c +++ b/src/test/test-unaligned.c @@ -18,6 +18,7 @@ ***/ #include "unaligned.h" +#include "sparse-endian.h" #include "util.h" static uint8_t data[] = { @@ -28,65 +29,65 @@ static uint8_t data[] = { int main(int argc, const char *argv[]) { uint8_t scratch[16]; - assert_se(unaligned_read_be16((be16_t*)&data[0]) == 0x0001); - assert_se(unaligned_read_be16((be16_t*)&data[1]) == 0x0102); + assert_se(unaligned_read_be16(&data[0]) == 0x0001); + assert_se(unaligned_read_be16(&data[1]) == 0x0102); - assert_se(unaligned_read_be32((be32_t*)&data[0]) == 0x00010203); - assert_se(unaligned_read_be32((be32_t*)&data[1]) == 0x01020304); - assert_se(unaligned_read_be32((be32_t*)&data[2]) == 0x02030405); - assert_se(unaligned_read_be32((be32_t*)&data[3]) == 0x03040506); + assert_se(unaligned_read_be32(&data[0]) == 0x00010203); + assert_se(unaligned_read_be32(&data[1]) == 0x01020304); + assert_se(unaligned_read_be32(&data[2]) == 0x02030405); + assert_se(unaligned_read_be32(&data[3]) == 0x03040506); - assert_se(unaligned_read_be64((be64_t*)&data[0]) == 0x0001020304050607); - assert_se(unaligned_read_be64((be64_t*)&data[1]) == 0x0102030405060708); - assert_se(unaligned_read_be64((be64_t*)&data[2]) == 0x0203040506070809); - assert_se(unaligned_read_be64((be64_t*)&data[3]) == 0x030405060708090a); - assert_se(unaligned_read_be64((be64_t*)&data[4]) == 0x0405060708090a0b); - assert_se(unaligned_read_be64((be64_t*)&data[5]) == 0x05060708090a0b0c); - assert_se(unaligned_read_be64((be64_t*)&data[6]) == 0x060708090a0b0c0d); - assert_se(unaligned_read_be64((be64_t*)&data[7]) == 0x0708090a0b0c0d0e); + assert_se(unaligned_read_be64(&data[0]) == 0x0001020304050607); + assert_se(unaligned_read_be64(&data[1]) == 0x0102030405060708); + assert_se(unaligned_read_be64(&data[2]) == 0x0203040506070809); + assert_se(unaligned_read_be64(&data[3]) == 0x030405060708090a); + assert_se(unaligned_read_be64(&data[4]) == 0x0405060708090a0b); + assert_se(unaligned_read_be64(&data[5]) == 0x05060708090a0b0c); + assert_se(unaligned_read_be64(&data[6]) == 0x060708090a0b0c0d); + assert_se(unaligned_read_be64(&data[7]) == 0x0708090a0b0c0d0e); zero(scratch); - unaligned_write_be16((uint16_t*)&scratch[0], 0x0001); + unaligned_write_be16(&scratch[0], 0x0001); assert_se(memcmp(&scratch[0], &data[0], sizeof(uint16_t)) == 0); zero(scratch); - unaligned_write_be16((uint16_t*)&scratch[1], 0x0102); + unaligned_write_be16(&scratch[1], 0x0102); assert_se(memcmp(&scratch[1], &data[1], sizeof(uint16_t)) == 0); zero(scratch); - unaligned_write_be32((be32_t*)&scratch[0], 0x00010203); + unaligned_write_be32(&scratch[0], 0x00010203); assert_se(memcmp(&scratch[0], &data[0], sizeof(uint32_t)) == 0); zero(scratch); - unaligned_write_be32((be32_t*)&scratch[1], 0x01020304); + unaligned_write_be32(&scratch[1], 0x01020304); assert_se(memcmp(&scratch[1], &data[1], sizeof(uint32_t)) == 0); zero(scratch); - unaligned_write_be32((be32_t*)&scratch[2], 0x02030405); + unaligned_write_be32(&scratch[2], 0x02030405); assert_se(memcmp(&scratch[2], &data[2], sizeof(uint32_t)) == 0); zero(scratch); - unaligned_write_be32((be32_t*)&scratch[3], 0x03040506); + unaligned_write_be32(&scratch[3], 0x03040506); assert_se(memcmp(&scratch[3], &data[3], sizeof(uint32_t)) == 0); zero(scratch); - unaligned_write_be64((be64_t*)&scratch[0], 0x0001020304050607); + unaligned_write_be64(&scratch[0], 0x0001020304050607); assert_se(memcmp(&scratch[0], &data[0], sizeof(uint64_t)) == 0); zero(scratch); - unaligned_write_be64((be64_t*)&scratch[1], 0x0102030405060708); + unaligned_write_be64(&scratch[1], 0x0102030405060708); assert_se(memcmp(&scratch[1], &data[1], sizeof(uint64_t)) == 0); zero(scratch); - unaligned_write_be64((be64_t*)&scratch[2], 0x0203040506070809); + unaligned_write_be64(&scratch[2], 0x0203040506070809); assert_se(memcmp(&scratch[2], &data[2], sizeof(uint64_t)) == 0); zero(scratch); - unaligned_write_be64((be64_t*)&scratch[3], 0x030405060708090a); + unaligned_write_be64(&scratch[3], 0x030405060708090a); assert_se(memcmp(&scratch[3], &data[3], sizeof(uint64_t)) == 0); zero(scratch); - unaligned_write_be64((be64_t*)&scratch[4], 0x0405060708090a0b); + unaligned_write_be64(&scratch[4], 0x0405060708090a0b); assert_se(memcmp(&scratch[4], &data[4], sizeof(uint64_t)) == 0); zero(scratch); - unaligned_write_be64((be64_t*)&scratch[5], 0x05060708090a0b0c); + unaligned_write_be64(&scratch[5], 0x05060708090a0b0c); assert_se(memcmp(&scratch[5], &data[5], sizeof(uint64_t)) == 0); zero(scratch); - unaligned_write_be64((be64_t*)&scratch[6], 0x060708090a0b0c0d); + unaligned_write_be64(&scratch[6], 0x060708090a0b0c0d); assert_se(memcmp(&scratch[6], &data[6], sizeof(uint64_t)) == 0); zero(scratch); - unaligned_write_be64((be64_t*)&scratch[7], 0x0708090a0b0c0d0e); + unaligned_write_be64(&scratch[7], 0x0708090a0b0c0d0e); assert_se(memcmp(&scratch[7], &data[7], sizeof(uint64_t)) == 0); } |