Browse Source

string_character_counter() definiert und einen Test für die Funktion erstellt

remotes/origin/habib
Habib 11 months ago
parent
commit
c34a836381
  1. 10
      src/c/funktionen.c
  2. 15
      src/test/test_funktionen.c

10
src/c/funktionen.c

@ -53,4 +53,14 @@ int x_wins_01_11_21(char board[][3]) {
if (board[0][1] == 'X' && board[1][1] == 'X' && board[2][1] == 'X') { if (board[0][1] == 'X' && board[1][1] == 'X' && board[2][1] == 'X') {
return 1; return 1;
} }
}
int string_character_counter(char string[]) {
int stringLength = 0;
for (int i = 0; string[i] != '\0'; i++) {
stringLength++;
}
return stringLength;
} }

15
src/test/test_funktionen.c

@ -106,4 +106,19 @@ void test_x_wins_onIndex_01_11_21(void)
TEST_ASSERT_EQUAL_INT(expected, actual); TEST_ASSERT_EQUAL_INT(expected, actual);
} }
void test_stringLaenge_von_Kokosnuss(void)
{
/* arrange */
int actual;
int expected = 9;
char string[] = "Kokosnuss";
/* act */
actual = string_character_counter(string);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, actual);
}
#endif #endif
Loading…
Cancel
Save