Browse Source

Test für zu große Wertübergabe bei getWordFromList + Anpassung im ProduktivCode

remotes/origin/tim
fdai7727 11 months ago
parent
commit
0fb0f02821
  1. 9
      src/main/c/Tim/hangman.c
  2. 13
      src/test/c/Tim/test_hangman.c

9
src/main/c/Tim/hangman.c

@ -55,6 +55,13 @@ void hangman()
char* getWordFromList(int x)
{
return wordlist[x];
if(x<LISTSIZE)
{
return wordlist[x];
}
else
{
return "Index nicht vorhanden";
}
}

13
src/test/c/Tim/test_hangman.c

@ -36,4 +36,17 @@ void test_getWordFromList_Kleiderschrank_5()
strcpy(actualResult,getWordFromList(pos));
//assert
TEST_ASSERT_EQUAL_STRING(expectedResult, actualResult);
}
void test_getWordFromList_IndexOutOfList()
{
//arrange
int pos = 15;
char expectedResult[] = "Index nicht vorhanden";
//act
char actualResult[30];
strcpy(actualResult,getWordFromList(pos));
//assert
TEST_ASSERT_EQUAL_STRING(expectedResult, actualResult);
}
Loading…
Cancel
Save