From 6f595fb2dd7d40d2cd843090c77083f116c41725 Mon Sep 17 00:00:00 2001 From: fdai7057 Date: Mon, 6 Feb 2023 16:54:17 +0100 Subject: [PATCH] Implementation of unit test for calculateStringLength(). --- src/helperFunctions.c | 4 ---- test/test_helperFunctions.c | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/helperFunctions.c b/src/helperFunctions.c index 2fc211e..2f61921 100644 --- a/src/helperFunctions.c +++ b/src/helperFunctions.c @@ -1,10 +1,6 @@ #include "helperFunctions.h" /*Code written by Julius Philipp Engel, fdai7057*/ -int main(){ - -} - char *stringConcatenation(char *string_1, char *string_2) { int lengthStringOne = strlen(string_1); diff --git a/test/test_helperFunctions.c b/test/test_helperFunctions.c index da8bc7f..0b42d1a 100644 --- a/test/test_helperFunctions.c +++ b/test/test_helperFunctions.c @@ -4,6 +4,15 @@ #include #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