Browse Source

refactoring: The function test_toUnsignedInteger() is modified. The test now contains more test cases than before. Variables names are modified to increase readability. Assertions written under each other have been replaced with loops that verify them.

remotes/origin/development
fdai7057 2 years ago
parent
commit
a18a4fed92
  1. 34
      test/test_StringManipulation.c

34
test/test_StringManipulation.c

@ -6,17 +6,31 @@
void test_toUnsignedInteger()
{
/*variables*/
char *n1 = "176", *n2 = "199", *n3 = "200", *n4 = "500", *n5 = "600", *n6 = "700";
/*assertions*/
TEST_ASSERT_EQUAL_INT(176,toUnsignedInteger(n1));
TEST_ASSERT_EQUAL_INT(199,toUnsignedInteger(n2));
TEST_ASSERT_EQUAL_INT(200,toUnsignedInteger(n3));
TEST_ASSERT_EQUAL_INT(500,toUnsignedInteger(n4));
TEST_ASSERT_EQUAL_INT(600,toUnsignedInteger(n5));
TEST_ASSERT_EQUAL_INT(700,toUnsignedInteger(n6));
}
/*test block 1*/
char *strings[] = {"111","123","542","994","9000","8384","6473","12345","57837","78387","93276","1000","8444","48484"};
int expected[] = {111,123,542,994,9000,8384,6473,12345,57837,78387,93276,1000,8444,48484};
int length = sizeof(expected)/sizeof(int);
for(int i=0;i<length;++i){
TEST_ASSERT_EQUAL_INT(expected[i], toUnsignedInteger(strings[i]));
}
/*test block 2*/
char *strings_2[] = {"9999","99999","9","99","999","0","19","10","90","8765"};
int expected_2[] = {9999,99999,9,99,999,0,19,10,90,8765};
length = sizeof(expected_2)/sizeof(int);
for(int i=0;i<length;++i){
TEST_ASSERT_EQUAL_INT(expected_2[i], toUnsignedInteger(strings_2[i]));
}
/*test block 3*/
char *strings_3[] = {"0","1","1","2","3","5","8","13","21","34","55","89","144","233"};
int expected_3[] = {0,1,1,2,3,5,8,13,21,34,55,89,144,233};
length = sizeof(expected_3)/sizeof(int);
for(int i=0;i<length;++i){
TEST_ASSERT_EQUAL_INT(expected_3[i], toUnsignedInteger(strings_3[i]));
}
}
void test_everyCharacterIsDigit()
{
/*test block 1*/

Loading…
Cancel
Save