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