From 00423f02e1862ec2bac44b4c0a3acfb77b958f81 Mon Sep 17 00:00:00 2001 From: Sophia Weber Date: Sun, 28 Jan 2024 12:57:51 +0100 Subject: [PATCH] Add Whitespace Test with many Spaces fix Whitespace function --- src/inputHandling.c | 1 + test/test_inputHandling.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/inputHandling.c b/src/inputHandling.c index cf4893a..e7f7f61 100644 --- a/src/inputHandling.c +++ b/src/inputHandling.c @@ -26,6 +26,7 @@ void deleteWhitespace(char* formulaString, int length){ for (int j=stringPos; j < length; j++){ formulaString[j]=formulaString[j + 1]; } + stringPos--; } } } diff --git a/test/test_inputHandling.c b/test/test_inputHandling.c index eddc48a..9fb4730 100644 --- a/test/test_inputHandling.c +++ b/test/test_inputHandling.c @@ -5,6 +5,7 @@ #include "inputHandling.h" char halloWelt[]="Hallo Welt"; char halloWelt2[]="Hallo Welt"; +char halloWelt3[]="Ha llo W el t "; void setUp(void) { @@ -22,8 +23,14 @@ void test_inputHandling_deleteOneWhiteSpace(void) void test_inputHandling_deleteTwoWhiteSpaces(void) { - deleteWhitespace(halloWelt, 11); - TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt); + deleteWhitespace(halloWelt2, 11); + TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt2); +} + +void test_inputHandling_deleteManyWhiteSpaces(void) +{ + deleteWhitespace(halloWelt3, 16); + TEST_ASSERT_EQUAL_STRING("HalloWelt", halloWelt3); } #endif // TEST