From 8e9d66b8559db3fb76962465761e887a4e54ff52 Mon Sep 17 00:00:00 2001 From: Jason Peters Date: Mon, 5 Feb 2024 16:41:06 +0100 Subject: [PATCH] =?UTF-8?q?Test=20auf=20korrekte=20Ausgabe=20des=20Dreieck?= =?UTF-8?q?s=20inklusive=20fix=20des=20bef=C3=BCllens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Jason/ASCII_art.c | 2 +- src/test/c/Jason/test_ASCII_art.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/c/Jason/ASCII_art.c b/src/main/c/Jason/ASCII_art.c index 9242f53..c0dd61c 100644 --- a/src/main/c/Jason/ASCII_art.c +++ b/src/main/c/Jason/ASCII_art.c @@ -305,7 +305,7 @@ void befuellenDesDreiecksMitZeilenumbruechen(char arr[], int gesamtzeilen, int a stelleFuerZeilenumbruch += (zeile+2); } - arr[arraygroesse] = '\0'; + arr[arraygroesse -1] = '\0'; } void raketeBegruessung(){ diff --git a/src/test/c/Jason/test_ASCII_art.c b/src/test/c/Jason/test_ASCII_art.c index d6af16c..c0edbf7 100644 --- a/src/test/c/Jason/test_ASCII_art.c +++ b/src/test/c/Jason/test_ASCII_art.c @@ -126,4 +126,18 @@ void test_korrekteBerechnungAufMaximaleGroesseDesDreiecksBeiGrossenZahlen() { //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_wirdKleinesDreieckKorrektBefuellt(void){ + // arrange + char expectedMessage[] = "X\nXX"; + + // act + char message[6]; + befuellenDesDreiecksMitX(message, 5); + befuellenDesDreiecksMitZeilenumbruechen(message, 2, 5); + + + // assert + TEST_ASSERT_EQUAL_STRING(expectedMessage, message); } \ No newline at end of file