Browse Source

refactoring: add more test cases and use easy names for arrays to increase readability. Assertions writen under each other have been replaced with loops that verify them.

remotes/origin/development
fdai7057 2 years ago
parent
commit
d7a102e3b1
  1. 23
      test/test_StringManipulation.c

23
test/test_StringManipulation.c

@ -6,14 +6,21 @@
void test_everyCharacterIsDigit()
{
/*test values*/
char str_1[] = "1234", str_2[] = "hey123", str_3[] = "good evening!", str_4[] = "äöü";
/*assertions*/
TEST_ASSERT_TRUE(everyCharacterIsDigit(str_1));
TEST_ASSERT_FALSE(everyCharacterIsDigit(str_2));
TEST_ASSERT_FALSE(everyCharacterIsDigit(str_3));
TEST_ASSERT_FALSE(everyCharacterIsDigit(str_4));
/*test block 1*/
char *expectTrue[] = {"0","11","222","3333","4444","134132","12352378","12847273","1237873","9992475","987232","34723873278","578347823783","758378723","44293884742",
"3184123872873","8912892383","18282828","55757575757528282","123823883282383282575757283832","99999999999999999999999999999999999","128321378","81293982139823","21412323"
"575757575754646464648383838383","1298557648298219821398129381928391283918238912831283928391283129839281391283918238912391238912839182391239857517828"};
int length = sizeof(expectTrue)/sizeof(char *);
for(int i=0;i<length;++i){
TEST_ASSERT_TRUE(everyCharacterIsDigit(expectTrue[i]));
}
/*test block 2*/
char *expectFalse[] = {"a","bcd","dhdd","3asad87","askj","nxbdj","489sjk2kj","kjasjkd38234","aksjlas","bcbc838ch","akjsjkdjkq919191","askjsdakj492","kasjcncn","9919a19","cbajsh","askjajkd","ajshdasjh","jyxhyxjchyx","kasjdakj","vbvb88888888888888828282828282828askjh"};
length = sizeof(expectFalse)/sizeof(char *);
for(int i=0;i<length;++i){
TEST_ASSERT_FALSE(everyCharacterIsDigit(expectFalse[i]));
}
}
void test_power()

Loading…
Cancel
Save