Browse Source

Konflikte gelöst

remotes/origin/siamak
Siamak 11 months ago
parent
commit
f28b4fca39
  1. 28
      src/c/funktionen.c
  2. 18
      src/c/funktionen.h
  3. 59
      src/test/test_funktionen.c

28
src/c/funktionen.c

@ -71,6 +71,30 @@ int x_wins_00_01_02(char board[][3]) {
} }
} }
int x_wins_10_11_12(char board[][3]) {
if (board[1][0] == 'X' && board[1][1] == 'X' && board[1][2] == 'X') {
return 1;
}
}
int x_wins_20_21_22(char board[][3]) {
if (board[2][0] == 'X' && board[2][1] == 'X' && board[2][2] == 'X') {
return 1;
}
}
int x_wins_00_11_22(char board[][3]) {
if (board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X') {
return 1;
}
}
int x_wins_02_11_20(char board[][3]) {
if (board[0][2] == 'X' && board[1][1] == 'X' && board[2][0] == 'X') {
return 1;
}
}
int o_wins_00_10_20(char board[][3]) { int o_wins_00_10_20(char board[][3]) {
if (board[0][0] == 'O' && board[1][0] == 'O' && board[2][0] == 'O') { if (board[0][0] == 'O' && board[1][0] == 'O' && board[2][0] == 'O') {
return 1; return 1;
@ -310,3 +334,7 @@ float average(float x, float y) {
float remainderValue(float x, float y) { float remainderValue(float x, float y) {
return fmod(x, y); return fmod(x, y);
} }
float f(float m) {
return m * 9.81;
}

18
src/c/funktionen.h

@ -35,9 +35,22 @@ int x_wins_02_12_22(char board[][3]);
int x_wins_00_01_02(char board[][3]); int x_wins_00_01_02(char board[][3]);
//prüft, ob X bei Index 00, 01, 02 ist //prüft, ob X bei Index 00, 01, 02 ist
int o_wins_00_10_20(char board[][3])
int o_wins_00_10_20(char board[][3]);
// prüft, ob O bei Index 00, 10, 20 ist. // prüft, ob O bei Index 00, 10, 20 ist.
int x_wins_10_11_12(char board[][3]);
//prüft, ob X bei Index 10, 11, 12 ist
int x_wins_20_21_22(char board[][3]);
// prüft, ob X bei Index 20, 21, 22 ist
int x_wins_00_11_22(char board[][3]);
// prüft, ob X bei Index 00, 11, 22 ist
int x_wins_02_11_20(char board[][3]);
// prüft, ob X bei Index 02, 11, 20 ist
>>>>>>> 2db6d7e7b64f8bdbc0a3390d95c27edc00af7924
int string_character_counter(char string[]); int string_character_counter(char string[]);
// liefert die Länge eines Strings zurück // liefert die Länge eines Strings zurück
@ -142,4 +155,7 @@ float average(float x, float y);
// Function to calculate the remainder of division between two numbers // Function to calculate the remainder of division between two numbers
float remainderValue(float x, float y); float remainderValue(float x, float y);
float f(float m);
// berechnet die Gewichtkraft
#endif #endif

59
src/test/test_funktionen.c

@ -228,6 +228,51 @@ void test_o_wins_onIndex_00_10_20(void)
TEST_ASSERT_EQUAL_INT(expected, actual); TEST_ASSERT_EQUAL_INT(expected, actual);
} }
void test_x_wins_onIndex_20_21_22(void)
{
/* arrange */
int actual;
int expected = 1;
char board[][3] = {{' ',' ',' '}, {' ',' ',' '}, {'X','X','X'}};
/* act */
actual = x_wins_20_21_22(board);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, actual);
}
void test_x_wins_onIndex_00_11_22(void)
{
/* arrange */
int actual;
int expected = 1;
char board[][3] = {{'X',' ',' '}, {' ','X',' '}, {' ',' ','X'}};
/* act */
actual = x_wins_00_11_22(board);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, actual);
}
void test_x_wins_onIndex_02_11_20(void)
{
/* arrange */
int actual;
int expected = 1;
char board[][3] = {{' ',' ','X'}, {' ','X',' '}, {'X',' ',' '}};
/* act */
actual = x_wins_02_11_20(board);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, actual);
}
void test_stringLaenge_von_Kokosnuss(void) void test_stringLaenge_von_Kokosnuss(void)
{ {
/* arrange */ /* arrange */
@ -379,4 +424,18 @@ void test_tangentDegrees(void) {
// Add more test cases for different inputs and expected outputs // Add more test cases for different inputs and expected outputs
} }
void test_weight_at_mass100(void)
{
/* arrange */
float actual;
float expected = 981;
/* act */;
float m = 100;
actual = f(m);
/* assert */
TEST_ASSERT_EQUAL_FLOAT(expected, actual);
}
#endif #endif
Loading…
Cancel
Save