Skip to content

Commit

Permalink
Change type casts when converting from text.
Browse files Browse the repository at this point in the history
Casts were to (uint8_t *) and const was added to make (const uint8_t *).
  • Loading branch information
sbertin-telular committed Nov 6, 2020
1 parent ed6c149 commit fa3979f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/convert_numbers_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void test_utils_textToInt(void)
int64_t res;
int converted;

converted = utils_textToInt((uint8_t*)ints_text[i], strlen(ints_text[i]), &res);
converted = utils_textToInt((const uint8_t*)ints_text[i], strlen(ints_text[i]), &res);

CU_ASSERT(converted);
if (converted)
Expand All @@ -70,7 +70,7 @@ static void test_utils_textToUInt(void)
uint64_t res;
int converted;

converted = utils_textToUInt((uint8_t*)uints_text[i], strlen(uints_text[i]), &res);
converted = utils_textToUInt((const uint8_t*)uints_text[i], strlen(uints_text[i]), &res);

CU_ASSERT(converted);
if (converted)
Expand All @@ -95,7 +95,7 @@ static void test_utils_textToFloat(void)
double res;
int converted;

converted = utils_textToFloat((uint8_t*)floats_text[i], strlen(floats_text[i]), &res, false);
converted = utils_textToFloat((const uint8_t*)floats_text[i], strlen(floats_text[i]), &res, false);

CU_ASSERT(converted);
if (converted)
Expand All @@ -120,7 +120,7 @@ static void test_utils_textToFloatExponential(void)
double res;
int converted;

converted = utils_textToFloat((uint8_t*)floats_exponential[i], strlen(floats_exponential[i]), &res, true);
converted = utils_textToFloat((const uint8_t*)floats_exponential[i], strlen(floats_exponential[i]), &res, true);

CU_ASSERT(converted);
if (converted)
Expand All @@ -145,21 +145,21 @@ static void test_utils_textToObjLink(void)
uint16_t objectId;
uint16_t objectInstanceId;
CU_ASSERT_EQUAL(utils_textToObjLink(NULL, 0, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((uint8_t*)"", 0, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((uint8_t*)":", 1, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((uint8_t*)"0:", 2, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((uint8_t*)":0", 2, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((uint8_t*)"0:0", 3, &objectId, &objectInstanceId), 1);
CU_ASSERT_EQUAL(utils_textToObjLink((const uint8_t*)"", 0, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((const uint8_t*)":", 1, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((const uint8_t*)"0:", 2, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((const uint8_t*)":0", 2, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((const uint8_t*)"0:0", 3, &objectId, &objectInstanceId), 1);
CU_ASSERT_EQUAL(objectId, 0);
CU_ASSERT_EQUAL(objectInstanceId, 0);
CU_ASSERT_EQUAL(utils_textToObjLink((uint8_t*)"1:2", 3, &objectId, &objectInstanceId), 1);
CU_ASSERT_EQUAL(utils_textToObjLink((const uint8_t*)"1:2", 3, &objectId, &objectInstanceId), 1);
CU_ASSERT_EQUAL(objectId, 1);
CU_ASSERT_EQUAL(objectInstanceId, 2);
CU_ASSERT_EQUAL(utils_textToObjLink((uint8_t*)"65535:65535", 11, &objectId, &objectInstanceId), 1);
CU_ASSERT_EQUAL(utils_textToObjLink((const uint8_t*)"65535:65535", 11, &objectId, &objectInstanceId), 1);
CU_ASSERT_EQUAL(objectId, 65535);
CU_ASSERT_EQUAL(objectInstanceId, 65535);
CU_ASSERT_EQUAL(utils_textToObjLink((uint8_t*)"65536:65535", 11, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((uint8_t*)"65535:65536", 11, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((const uint8_t*)"65536:65535", 11, &objectId, &objectInstanceId), 0);
CU_ASSERT_EQUAL(utils_textToObjLink((const uint8_t*)"65535:65536", 11, &objectId, &objectInstanceId), 0);
}

static void test_utils_intToText(void)
Expand Down

0 comments on commit fa3979f

Please sign in to comment.