diff --git a/build/test/cache/test_duellist_spielesammlung_projekt.c b/build/test/cache/test_duellist_spielesammlung_projekt.c index e0df2e2..d1af239 100644 --- a/build/test/cache/test_duellist_spielesammlung_projekt.c +++ b/build/test/cache/test_duellist_spielesammlung_projekt.c @@ -962,4 +962,530 @@ void test_calculate_mines_HeightWidthFinal(void) ), (UNITY_UINT)(423), UNITY_DISPLAY_STYLE_INT); +} + +void test_generateRandomNumber_withinValidRange(void) + +{ + + + + + + + + int result = generateRandomNumber(1, 100); + + + + + + do {if ((result >= 1 && result <= 100)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(459)));}} while(0); + +} + + + +void test_addition(void) + +{ + + + + int a = 5; + + int b = 10; + + + + + + int result = addition(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((15)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(472), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_subtraction(void) + +{ + + + + int a = 15; + + int b = 10; + + + + + + int result = subtraction(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(485), UNITY_DISPLAY_STYLE_INT); + +} + + + + + +void test_multiplication(void) + +{ + + + + int a = 5; + + int b = 10; + + + + + + int result = multiplication(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((50)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(499), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_division(void) + +{ + + + + int a = 15; + + int b = 3; + + + + + + int result = division(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(512), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_division_byZero_returnsZero(void) + +{ + + + + int num1 = 8; + + int num2 = 0; + + + + + + int result = division(num1, num2); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(525), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_modulo(void) + +{ + + + + int a = 15; + + int b = 7; + + + + + + int result = modulo(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(538), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_compare_equalNumbers(void) + +{ + + + + int a = 5; + + int b = 5; + + + + + + int result = compare(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(551), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_compare_aLessThanB(void) + +{ + + + + int a = 3; + + int b = 8; + + + + + + int result = compare(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(564), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_compare_aGreaterThanB(void) + +{ + + + + int a = 10; + + int b = 7; + + + + + + int result = compare(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(577), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_exponentiation(void) + +{ + + + + int base = 2; + + int exponent = 3; + + + + + + int result = exponentiation(base, exponent); + + + + + + UnityAssertEqualNumber((UNITY_INT)((8)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(590), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_exponentiation_negativeExponent(void) + +{ + + + + int base = 2; + + int exponent = -3; + + + + + + int result = exponentiation(base, exponent); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(603), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_squareRoot_validNumber(void) + +{ + + + + int number = 25; + + + + + + int result = squareRoot(number); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(615), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_squareRoot_negativeNumber(void) + +{ + + + + int number = -5; + + + + + + int result = squareRoot(number); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(627), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_displayResult_correctResult(void) + +{ + + + + int correctAnswers = 3; + + int totalQuestions = 5; + + + + + + displayResult(correctAnswers, totalQuestions); + + + + + + + +} + + + +void test_displayMenu_validMenu(void) + +{ + + + + + + + + + + + + displayMenu(); + +} + + + +void test_getUserChoice_invalidInput(void) + +{ + + + + freopen("invalid_input.txt", "r", + + (&_iob[0]) + + ); + + + + + + int result = getUserChoice(); + + + + + + + +} + + + +void test_playGame_correctResult(void) + +{ + + + + + + + + playGame(); + +} + + + +void test_getUserAnswer_invalidInput(void) + +{ + + + + freopen("invalid_input.txt", "r", + + (&_iob[0]) + + ); + + + + + + int result = getUserAnswer(); + + + + + + + } diff --git a/build/test/out/c/duellist-spielesammlung-projekt.o b/build/test/out/c/duellist-spielesammlung-projekt.o index bf44bba..f0f1604 100644 Binary files a/build/test/out/c/duellist-spielesammlung-projekt.o and b/build/test/out/c/duellist-spielesammlung-projekt.o differ diff --git a/build/test/out/c/test_duellist_spielesammlung_projekt.o b/build/test/out/c/test_duellist_spielesammlung_projekt.o index b653d98..e6b30ca 100644 Binary files a/build/test/out/c/test_duellist_spielesammlung_projekt.o and b/build/test/out/c/test_duellist_spielesammlung_projekt.o differ diff --git a/build/test/out/c/test_duellist_spielesammlung_projekt_runner.o b/build/test/out/c/test_duellist_spielesammlung_projekt_runner.o index f30e0c4..193a3bd 100644 Binary files a/build/test/out/c/test_duellist_spielesammlung_projekt_runner.o and b/build/test/out/c/test_duellist_spielesammlung_projekt_runner.o differ diff --git a/build/test/out/test_duellist_spielesammlung_projekt.out b/build/test/out/test_duellist_spielesammlung_projekt.out deleted file mode 100644 index f4f0aa5..0000000 Binary files a/build/test/out/test_duellist_spielesammlung_projekt.out and /dev/null differ diff --git a/build/test/preprocess/files/test_duellist_spielesammlung_projekt.c b/build/test/preprocess/files/test_duellist_spielesammlung_projekt.c index e0df2e2..d1af239 100644 --- a/build/test/preprocess/files/test_duellist_spielesammlung_projekt.c +++ b/build/test/preprocess/files/test_duellist_spielesammlung_projekt.c @@ -962,4 +962,530 @@ void test_calculate_mines_HeightWidthFinal(void) ), (UNITY_UINT)(423), UNITY_DISPLAY_STYLE_INT); +} + +void test_generateRandomNumber_withinValidRange(void) + +{ + + + + + + + + int result = generateRandomNumber(1, 100); + + + + + + do {if ((result >= 1 && result <= 100)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(459)));}} while(0); + +} + + + +void test_addition(void) + +{ + + + + int a = 5; + + int b = 10; + + + + + + int result = addition(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((15)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(472), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_subtraction(void) + +{ + + + + int a = 15; + + int b = 10; + + + + + + int result = subtraction(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(485), UNITY_DISPLAY_STYLE_INT); + +} + + + + + +void test_multiplication(void) + +{ + + + + int a = 5; + + int b = 10; + + + + + + int result = multiplication(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((50)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(499), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_division(void) + +{ + + + + int a = 15; + + int b = 3; + + + + + + int result = division(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(512), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_division_byZero_returnsZero(void) + +{ + + + + int num1 = 8; + + int num2 = 0; + + + + + + int result = division(num1, num2); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(525), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_modulo(void) + +{ + + + + int a = 15; + + int b = 7; + + + + + + int result = modulo(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(538), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_compare_equalNumbers(void) + +{ + + + + int a = 5; + + int b = 5; + + + + + + int result = compare(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(551), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_compare_aLessThanB(void) + +{ + + + + int a = 3; + + int b = 8; + + + + + + int result = compare(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(564), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_compare_aGreaterThanB(void) + +{ + + + + int a = 10; + + int b = 7; + + + + + + int result = compare(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(577), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_exponentiation(void) + +{ + + + + int base = 2; + + int exponent = 3; + + + + + + int result = exponentiation(base, exponent); + + + + + + UnityAssertEqualNumber((UNITY_INT)((8)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(590), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_exponentiation_negativeExponent(void) + +{ + + + + int base = 2; + + int exponent = -3; + + + + + + int result = exponentiation(base, exponent); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(603), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_squareRoot_validNumber(void) + +{ + + + + int number = 25; + + + + + + int result = squareRoot(number); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(615), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_squareRoot_negativeNumber(void) + +{ + + + + int number = -5; + + + + + + int result = squareRoot(number); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(627), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_displayResult_correctResult(void) + +{ + + + + int correctAnswers = 3; + + int totalQuestions = 5; + + + + + + displayResult(correctAnswers, totalQuestions); + + + + + + + +} + + + +void test_displayMenu_validMenu(void) + +{ + + + + + + + + + + + + displayMenu(); + +} + + + +void test_getUserChoice_invalidInput(void) + +{ + + + + freopen("invalid_input.txt", "r", + + (&_iob[0]) + + ); + + + + + + int result = getUserChoice(); + + + + + + + +} + + + +void test_playGame_correctResult(void) + +{ + + + + + + + + playGame(); + +} + + + +void test_getUserAnswer_invalidInput(void) + +{ + + + + freopen("invalid_input.txt", "r", + + (&_iob[0]) + + ); + + + + + + int result = getUserAnswer(); + + + + + + + } diff --git a/build/test/results/test_duellist_spielesammlung_projekt.pass b/build/test/results/test_duellist_spielesammlung_projekt.pass deleted file mode 100644 index 35a4440..0000000 --- a/build/test/results/test_duellist_spielesammlung_projekt.pass +++ /dev/null @@ -1,130 +0,0 @@ ---- -:source: - :path: src/test - :file: test_duellist_spielesammlung_projekt.c -:successes: -- :test: test_coinflip_x_starts - :line: 11 - :message: '' - :unity_test_time: 0 -- :test: test_coinflip_o_starts - :line: 23 - :message: '' - :unity_test_time: 0 -- :test: test_vertical_win - :line: 35 - :message: '' - :unity_test_time: 0 -- :test: test_horizontal_win - :line: 49 - :message: '' - :unity_test_time: 0 -- :test: test_diagonal_win - :line: 62 - :message: '' - :unity_test_time: 0 -- :test: test_valid_move_and_switch - :line: 76 - :message: '' - :unity_test_time: 0 -- :test: test_invalid_input - :line: 92 - :message: '' - :unity_test_time: 0 -- :test: test_valid_input - :line: 106 - :message: '' - :unity_test_time: 0 -- :test: test_invalid_input_negative_row - :line: 121 - :message: '' - :unity_test_time: 0 -- :test: test_invalid_input_overflow_column - :line: 135 - :message: '' - :unity_test_time: 0 -- :test: test_NumberOfMoves_returns_correct_number_of_moves - :line: 149 - :message: '' - :unity_test_time: 0 -- :test: test_BoardFull_returns_false_when_board_is_not_full - :line: 163 - :message: '' - :unity_test_time: 0 -- :test: test_BoardFull_returns_true_when_board_is_full - :line: 176 - :message: '' - :unity_test_time: 0 -- :test: test_CurrentPlayer_returns_correct_player - :line: 189 - :message: '' - :unity_test_time: 0 -- :test: test_FieldEmpty_returns_true_for_empty_field - :line: 202 - :message: '' - :unity_test_time: 0 -- :test: test_FieldEmpty_returns_false_for_nonempty_field - :line: 215 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_HeightWidthOne - :line: 228 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_WidthOne - :line: 242 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_NormalCase - :line: 256 - :message: '' - :unity_test_time: 0 -- :test: test_end_check_AllUncovered_NoMines - :line: 270 - :message: '' - :unity_test_time: 0 -- :test: test_create_minefield_ValidDimensions - :line: 289 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_HeightOne - :line: 314 - :message: '' - :unity_test_time: 0 -- :test: test_create_minefield_NegativeDimensions - :line: 328 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_HeightZero - :line: 342 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_HeightWidthNumber - :line: 356 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_HeightWidthAgan - :line: 370 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_HeightWidthRoundUp - :line: 384 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_HeightWidthNoRound - :line: 398 - :message: '' - :unity_test_time: 0 -- :test: test_calculate_mines_HeightWidthFinal - :line: 412 - :message: '' - :unity_test_time: 0 -:failures: [] -:ignores: [] -:counts: - :total: 29 - :passed: 29 - :failed: 0 - :ignored: 0 -:stdout: [] -:time: 0.19413550000172108 diff --git a/build/test/runners/test_duellist_spielesammlung_projekt_runner.c b/build/test/runners/test_duellist_spielesammlung_projekt_runner.c index 3817293..a71a0a8 100644 --- a/build/test/runners/test_duellist_spielesammlung_projekt_runner.c +++ b/build/test/runners/test_duellist_spielesammlung_projekt_runner.c @@ -39,6 +39,25 @@ extern void test_calculate_mines_HeightWidthAgan(void); extern void test_calculate_mines_HeightWidthRoundUp(void); extern void test_calculate_mines_HeightWidthNoRound(void); extern void test_calculate_mines_HeightWidthFinal(void); +extern void test_generateRandomNumber_withinValidRange(void); +extern void test_addition(void); +extern void test_subtraction(void); +extern void test_multiplication(void); +extern void test_division(void); +extern void test_division_byZero_returnsZero(void); +extern void test_modulo(void); +extern void test_compare_equalNumbers(void); +extern void test_compare_aLessThanB(void); +extern void test_compare_aGreaterThanB(void); +extern void test_exponentiation(void); +extern void test_exponentiation_negativeExponent(void); +extern void test_squareRoot_validNumber(void); +extern void test_squareRoot_negativeNumber(void); +extern void test_displayResult_correctResult(void); +extern void test_displayMenu_validMenu(void); +extern void test_getUserChoice_invalidInput(void); +extern void test_playGame_correctResult(void); +extern void test_getUserAnswer_invalidInput(void); /*=======Mock Management=====*/ @@ -132,6 +151,25 @@ int main(void) run_test(test_calculate_mines_HeightWidthRoundUp, "test_calculate_mines_HeightWidthRoundUp", 384); run_test(test_calculate_mines_HeightWidthNoRound, "test_calculate_mines_HeightWidthNoRound", 398); run_test(test_calculate_mines_HeightWidthFinal, "test_calculate_mines_HeightWidthFinal", 412); + run_test(test_generateRandomNumber_withinValidRange, "test_generateRandomNumber_withinValidRange", 451); + run_test(test_addition, "test_addition", 462); + run_test(test_subtraction, "test_subtraction", 475); + run_test(test_multiplication, "test_multiplication", 489); + run_test(test_division, "test_division", 502); + run_test(test_division_byZero_returnsZero, "test_division_byZero_returnsZero", 515); + run_test(test_modulo, "test_modulo", 528); + run_test(test_compare_equalNumbers, "test_compare_equalNumbers", 541); + run_test(test_compare_aLessThanB, "test_compare_aLessThanB", 554); + run_test(test_compare_aGreaterThanB, "test_compare_aGreaterThanB", 567); + run_test(test_exponentiation, "test_exponentiation", 580); + run_test(test_exponentiation_negativeExponent, "test_exponentiation_negativeExponent", 593); + run_test(test_squareRoot_validNumber, "test_squareRoot_validNumber", 606); + run_test(test_squareRoot_negativeNumber, "test_squareRoot_negativeNumber", 618); + run_test(test_displayResult_correctResult, "test_displayResult_correctResult", 630); + run_test(test_displayMenu_validMenu, "test_displayMenu_validMenu", 643); + run_test(test_getUserChoice_invalidInput, "test_getUserChoice_invalidInput", 653); + run_test(test_playGame_correctResult, "test_playGame_correctResult", 665); + run_test(test_getUserAnswer_invalidInput, "test_getUserAnswer_invalidInput", 673); return UnityEnd(); } diff --git a/src/main/duellist-spielesammlung-projekt.h b/src/main/duellist-spielesammlung-projekt.h index abcf2e4..d7a1b19 100644 --- a/src/main/duellist-spielesammlung-projekt.h +++ b/src/main/duellist-spielesammlung-projekt.h @@ -67,8 +67,8 @@ int minesweeper(); -int generateRandomNumber(int min, int max); -int addition(int a, int b); +int zufallszahl(int min, int max); +int add(int a, int b); int subtraction(int a, int b); int multiplication(int a, int b); int division(int a, int b);