Browse Source

Implementation of unit test for calculateStringLength().

remotes/origin/development
fdai7057 2 years ago
parent
commit
6f595fb2dd
  1. 4
      src/helperFunctions.c
  2. 9
      test/test_helperFunctions.c

4
src/helperFunctions.c

@ -1,10 +1,6 @@
#include "helperFunctions.h" #include "helperFunctions.h"
/*Code written by Julius Philipp Engel, fdai7057*/ /*Code written by Julius Philipp Engel, fdai7057*/
int main(){
}
char *stringConcatenation(char *string_1, char *string_2) char *stringConcatenation(char *string_1, char *string_2)
{ {
int lengthStringOne = strlen(string_1); int lengthStringOne = strlen(string_1);

9
test/test_helperFunctions.c

@ -4,6 +4,15 @@
#include <unity.h> #include <unity.h>
#include "../src/helperFunctions.c" #include "../src/helperFunctions.c"
void test_calculateStringLength()
{
char *testStrings[] = {"linux","table","book","men","woman","boy","girl","computer","old","new","water","fire","bright","dark","black","white"}; int expectedResults[] = {5,5,4,3,5,3,4,8,3,3,5,4,6,4,5,5};
int numberOfValues= sizeof(expectedResults) / sizeof(int);
for(int i=0;i<numberOfValues;++i){
TEST_ASSERT_EQUAL_INT(expectedResults[i], calculateStringLength(testStrings[i]));
}
}
void test_isLetterOfAlphabet() void test_isLetterOfAlphabet()
{ {
/*test block 1*/ /*test block 1*/

Loading…
Cancel
Save