From 560ed785a0687b35301a8c23b8bb9fc06b69d827 Mon Sep 17 00:00:00 2001 From: Isaac Turner Date: Thu, 3 Mar 2016 02:05:09 +0000 Subject: [PATCH] tests: use '#define' instead of 'const int' for array size --- dev/bit_array_test.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dev/bit_array_test.c b/dev/bit_array_test.c index 1d75a95..2f2e983 100644 --- a/dev/bit_array_test.c +++ b/dev/bit_array_test.c @@ -2401,31 +2401,32 @@ void test_get_set_bytes() { SUITE_START("get/set byte"); - const size_t nbytes = 8; - uint8_t bytes[nbytes] = {0x55,0x31,0x5A,0x12,0x02,0x31,0xC3,0x1E}; + #define NBYTES 8 + uint8_t bytes[NBYTES] = {0x55,0x31,0x5A,0x12,0x02,0x31,0xC3,0x1E}; size_t s, i; - BIT_ARRAY *arr = bit_array_create(nbytes*8); + BIT_ARRAY *arr = bit_array_create(NBYTES*8); // Set bytes using different offsets for(s = 0; s < 8; s++) { bit_array_clear_all(arr); - for(i = 0; i < nbytes-1; i++) { + for(i = 0; i < NBYTES-1; i++) { bit_array_set_word8(arr, i*8+s, bytes[i]); ASSERT(bit_array_get_word8(arr, i*8+s) == bytes[i]); } // Setting bytes doesn't extend the array - check last byte with masking - i = nbytes-1; + i = NBYTES-1; bit_array_set_word8(arr, i*8+s, bytes[i]); ASSERT(bit_array_get_word8(arr, i*8+s) == (bytes[i] & (0xff>>s))); // Check bits for(i = 0; i < s; i++) ASSERT(bit_array_get(arr, i) == 0); - for(i = s; i < nbytes*8; i++) + for(i = s; i < NBYTES*8; i++) ASSERT(bit_array_get(arr, i) == bitset_get(bytes, i-s)); } bit_array_free(arr); + #undef NBYTES SUITE_END(); }