Browse Source

Implementation der Tests für ein gültiges Parameter bei der Funktion getWordFromList

remotes/origin/tim
fdai7727 11 months ago
parent
commit
981856d4c7
  1. 3
      src/main/c/Tim/hangman.c
  2. 1
      src/main/c/Tim/hangman.h
  3. 23
      src/test/c/Tim/test_hangman.c

3
src/main/c/Tim/hangman.c

@ -6,8 +6,7 @@
#define LISTSIZE 10 #define LISTSIZE 10
#define MAX_WORD_LENGTH 30 #define MAX_WORD_LENGTH 30
char* getWordFromList(int);
int getParameters(int, char*);
char wordlist[LISTSIZE][MAX_WORD_LENGTH] = { char wordlist[LISTSIZE][MAX_WORD_LENGTH] = {
"Kartoffel", "Zigarette", "Haus", "Fenster", "Kartenleseettiketiergeraet", "Kartoffel", "Zigarette", "Haus", "Fenster", "Kartenleseettiketiergeraet",

1
src/main/c/Tim/hangman.h

@ -2,5 +2,6 @@
#define HANGMAN_H #define HANGMAN_H
void hangman(); void hangman();
char* getWordFromList(int);
#endif #endif

23
src/test/c/Tim/test_hangman.c

@ -1,5 +1,6 @@
#include "hangman.h" #include "hangman.h"
#include "unity.h" #include "unity.h"
#include <string.h>
@ -13,12 +14,26 @@ void tearDown(void)
} }
void test_ceedling_functionality()
void test_getWordFromList_Kartoffel_0()
{ {
//arrange //arrange
int expectedResult = 0;
int pos = 0;
char expectedResult[] = "Kartoffel";
//act //act
int actualResult = 0;
char actualResult[30];
strcpy(actualResult,getWordFromList(pos));
//assert //assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
TEST_ASSERT_EQUAL_STRING(expectedResult, actualResult);
}
void test_getWordFromList_Kleiderschrank_5()
{
//arrange
int pos = 5;
char expectedResult[] = "Kleiderschrank";
//act
char actualResult[30];
strcpy(actualResult,getWordFromList(pos));
//assert
TEST_ASSERT_EQUAL_STRING(expectedResult, actualResult);
} }
Loading…
Cancel
Save