summaryrefslogtreecommitdiffstats
path: root/libs/bitfield-c/tests
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-23 13:39:52 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 15:55:03 +0100
commit78e8a778786bf3f9050e55d99dd2b4338e8f4a8e (patch)
tree8dde7b0f50ea497f7a79ba60909570305328cb26 /libs/bitfield-c/tests
parentd76433ade0b75c8cc2b45fdae52a21d7fb28f526 (diff)
bitfield-c: use unsigned int instead of uint8_t
Use unsigned int instead of uint8_t upon destination and source array length. This is needed to handle gathered multi-frames message data which could be greater than 1 simple messages. Bug-AGL: SPEC-2988 Change-Id: I107bff383c2d0771dbc2a30770ec5c195b1c22ac Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'libs/bitfield-c/tests')
-rw-r--r--libs/bitfield-c/tests/8byte_tests.c8
-rw-r--r--libs/bitfield-c/tests/bitfield_tests.c30
-rw-r--r--libs/bitfield-c/tests/read_tests.c2
-rw-r--r--libs/bitfield-c/tests/write_tests.c4
4 files changed, 22 insertions, 22 deletions
diff --git a/libs/bitfield-c/tests/8byte_tests.c b/libs/bitfield-c/tests/8byte_tests.c
index 64554acc..ccb49cd9 100644
--- a/libs/bitfield-c/tests/8byte_tests.c
+++ b/libs/bitfield-c/tests/8byte_tests.c
@@ -173,8 +173,8 @@ END_TEST
START_TEST(test_eightbyte_get_byte)
{
uint64_t data = 0x00000000F34DFCFF;
- uint8_t result = eightbyte_get_byte(data, 0, false);
- uint8_t expected = 0x0;
+ unsigned int result = eightbyte_get_byte(data, 0, false);
+ unsigned int expected = 0x0;
ck_assert_int_eq(result, expected);
result = eightbyte_get_byte(data, 4, false);
@@ -198,8 +198,8 @@ END_TEST
START_TEST(test_eightbyte_get_nibble)
{
uint64_t data = 0x00000000F34DFCFF;
- uint8_t result = eightbyte_get_nibble(data, 0, false);
- uint8_t expected = 0x0;
+ unsigned int result = eightbyte_get_nibble(data, 0, false);
+ unsigned int expected = 0x0;
ck_assert_int_eq(result, expected);
result = eightbyte_get_nibble(data, 2, false);
diff --git a/libs/bitfield-c/tests/bitfield_tests.c b/libs/bitfield-c/tests/bitfield_tests.c
index b8c83b59..1e61dae5 100644
--- a/libs/bitfield-c/tests/bitfield_tests.c
+++ b/libs/bitfield-c/tests/bitfield_tests.c
@@ -4,8 +4,8 @@
START_TEST (test_get_byte)
{
- uint8_t data[4] = {0x12, 0x34, 0x56, 0x78};
- uint8_t result = get_byte(data, sizeof(data), 0);
+ unsigned int data[4] = {0x12, 0x34, 0x56, 0x78};
+ unsigned int result = get_byte(data, sizeof(data), 0);
ck_assert_int_eq(result, 0x12);
result = get_byte(data, sizeof(data), 3);
ck_assert_int_eq(result, 0x78);
@@ -14,7 +14,7 @@ END_TEST
START_TEST (test_set_nibble)
{
- uint8_t data[4] = {0};
+ unsigned int data[4] = {0};
fail_unless(set_nibble(0, 0x1, data, sizeof(data)));
fail_unless(set_nibble(1, 0x2, data, sizeof(data)));
fail_unless(set_nibble(2, 0x3, data, sizeof(data)));
@@ -28,7 +28,7 @@ END_TEST
START_TEST (test_set_bitfield)
{
- uint8_t data[4] = {0};
+ unsigned int data[4] = {0};
fail_unless(set_bitfield(0x12, 0, 8, data, sizeof(data)));
fail_unless(set_bitfield(bitmask(3), 10, 3, data, sizeof(data)));
ck_assert_int_eq(data[0], 0x12);
@@ -38,7 +38,7 @@ END_TEST
START_TEST (test_set_bitfield_doesnt_fit)
{
- uint8_t data[4] = {0};
+ unsigned int data[4] = {0};
fail_if(set_bitfield(0xffff, 0, 8, data, sizeof(data)));
ck_assert_int_eq(data[0], 0);
ck_assert_int_eq(data[1], 0);
@@ -49,8 +49,8 @@ END_TEST
START_TEST (test_get_nibble)
{
- uint8_t data[4] = {0x12, 0x34, 0x56, 0x78};
- uint8_t result = get_nibble(data, sizeof(data), 0);
+ unsigned int data[4] = {0x12, 0x34, 0x56, 0x78};
+ unsigned int result = get_nibble(data, sizeof(data), 0);
ck_assert_int_eq(result, 0x1);
result = get_nibble(data, sizeof(data), 1);
ck_assert_int_eq(result, 0x2);
@@ -61,8 +61,8 @@ END_TEST
START_TEST (test_get_bits_out_of_range)
{
- uint8_t data[4] = {0x12, 0x34, 0x56, 0x78};
- uint8_t result[4];
+ unsigned int data[4] = {0x12, 0x34, 0x56, 0x78};
+ unsigned int result[4];
fail_if(copy_bits_right_aligned(data, sizeof(data), 25, 16, result,
sizeof(result)));
}
@@ -70,8 +70,8 @@ END_TEST
START_TEST (test_get_bits)
{
- uint8_t data[4] = {0x12, 0x34, 0x56, 0x78};
- uint8_t result[4] = {0};
+ unsigned int data[4] = {0x12, 0x34, 0x56, 0x78};
+ unsigned int result[4] = {0};
fail_unless(copy_bits_right_aligned(data, sizeof(data), 0, 16, result,
sizeof(result)));
ck_assert_int_eq(result[2], 0x12);
@@ -81,8 +81,8 @@ END_TEST
START_TEST (test_copy_bytes)
{
- uint8_t data[4] = {0x12, 0x34, 0x56, 0x78};
- uint8_t result[4] = {0};
+ unsigned int data[4] = {0x12, 0x34, 0x56, 0x78};
+ unsigned int result[4] = {0};
fail_unless(copy_bytes_right_aligned(data, sizeof(data), 1, 3, result,
sizeof(result)));
ck_assert_int_eq(result[1], 0x34);
@@ -93,8 +93,8 @@ END_TEST
START_TEST (test_get_uneven_bits)
{
- uint8_t data[4] = {0x12, 0x34, 0x56, 0x78};
- uint8_t result[4] = {0};
+ unsigned int data[4] = {0x12, 0x34, 0x56, 0x78};
+ unsigned int result[4] = {0};
fail_unless(copy_bits_right_aligned(data, sizeof(data), 4, 12, result,
sizeof(result)));
ck_assert_int_eq(result[2], 0x2);
diff --git a/libs/bitfield-c/tests/read_tests.c b/libs/bitfield-c/tests/read_tests.c
index 5008cc52..192a0fe0 100644
--- a/libs/bitfield-c/tests/read_tests.c
+++ b/libs/bitfield-c/tests/read_tests.c
@@ -3,7 +3,7 @@
#include <canutil/read.h>
const uint64_t BIG_ENDIAN_TEST_DATA = __builtin_bswap64(0xEB00000000000000);
-const uint8_t ARRAY_TEST_DATA[] = {0xEB, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
+const unsigned int ARRAY_TEST_DATA[] = {0xEB, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
START_TEST (test_eightbyte_parse_float)
{
diff --git a/libs/bitfield-c/tests/write_tests.c b/libs/bitfield-c/tests/write_tests.c
index 4d5d8fc3..9e65b9d0 100644
--- a/libs/bitfield-c/tests/write_tests.c
+++ b/libs/bitfield-c/tests/write_tests.c
@@ -30,7 +30,7 @@ END_TEST
START_TEST (test_bitfield_encode_float)
{
- uint8_t data[8] = {0};
+ unsigned int data[8] = {0};
bitfield_encode_float(0, 1, 3, 1, 0, data, sizeof(data));
ck_assert_int_eq(data[0], 0);
ck_assert_int_eq(data[1], 0);
@@ -55,7 +55,7 @@ END_TEST
START_TEST (test_bitfield_encode_bool)
{
- uint8_t data[8] = {0};
+ unsigned int data[8] = {0};
bitfield_encode_bool(true, 1, 3, data, sizeof(data));
ck_assert_int_eq(data[0], 0x10);
ck_assert_int_eq(data[1], 0);