Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
tests.h@74:7b6568bc16d5, 2019-05-05 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Sun May 05 11:46:08 2019 +0000
- Revision:
- 74:7b6568bc16d5
- Parent:
- 69:55e309da7efd
- Child:
- 99:4841f326200f
edited the test file so that it tests more functionalities of the snake
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AhmedPlaymaker | 68:b9cfd27987ac | 1 | #ifndef TESTS_H |
AhmedPlaymaker | 68:b9cfd27987ac | 2 | #define TESTS_H |
AhmedPlaymaker | 68:b9cfd27987ac | 3 | |
AhmedPlaymaker | 68:b9cfd27987ac | 4 | #include "Snake-test.h" |
AhmedPlaymaker | 68:b9cfd27987ac | 5 | |
AhmedPlaymaker | 68:b9cfd27987ac | 6 | /** |
AhmedPlaymaker | 68:b9cfd27987ac | 7 | * @brief Run all the tests for this program |
AhmedPlaymaker | 68:b9cfd27987ac | 8 | * |
AhmedPlaymaker | 68:b9cfd27987ac | 9 | * @returns The number of tests that failed |
AhmedPlaymaker | 68:b9cfd27987ac | 10 | */ |
AhmedPlaymaker | 68:b9cfd27987ac | 11 | int run_all_tests() |
AhmedPlaymaker | 68:b9cfd27987ac | 12 | { |
AhmedPlaymaker | 74:7b6568bc16d5 | 13 | int number_of_failed_tests = 0; // A log of the number of tests that have failed |
AhmedPlaymaker | 68:b9cfd27987ac | 14 | |
AhmedPlaymaker | 74:7b6568bc16d5 | 15 | // Run the Snake_test_movement |
AhmedPlaymaker | 68:b9cfd27987ac | 16 | printf("Testing Snake_test_movement...\n"); |
AhmedPlaymaker | 74:7b6568bc16d5 | 17 | bool snake_movement_test_passed = Snake_test_movement(); |
AhmedPlaymaker | 68:b9cfd27987ac | 18 | |
AhmedPlaymaker | 68:b9cfd27987ac | 19 | // Print out the result of this test |
AhmedPlaymaker | 74:7b6568bc16d5 | 20 | if (snake_movement_test_passed) { |
AhmedPlaymaker | 74:7b6568bc16d5 | 21 | printf("...Passed!, no worries the game is alright\n"); |
AhmedPlaymaker | 69:55e309da7efd | 22 | } else { |
AhmedPlaymaker | 68:b9cfd27987ac | 23 | printf("...FAILED!\n"); |
AhmedPlaymaker | 74:7b6568bc16d5 | 24 | ++number_of_failed_tests; // Increment number of failures |
AhmedPlaymaker | 68:b9cfd27987ac | 25 | } |
AhmedPlaymaker | 69:55e309da7efd | 26 | |
AhmedPlaymaker | 68:b9cfd27987ac | 27 | |
AhmedPlaymaker | 68:b9cfd27987ac | 28 | // Finish by printing a summary of the tests |
AhmedPlaymaker | 74:7b6568bc16d5 | 29 | if (number_of_failed_tests > 0) { |
AhmedPlaymaker | 74:7b6568bc16d5 | 30 | printf("%d tests FAILED!\n", number_of_failed_tests); |
AhmedPlaymaker | 69:55e309da7efd | 31 | } else { |
AhmedPlaymaker | 68:b9cfd27987ac | 32 | printf("All tests passed!\n"); |
AhmedPlaymaker | 68:b9cfd27987ac | 33 | } |
AhmedPlaymaker | 68:b9cfd27987ac | 34 | |
AhmedPlaymaker | 74:7b6568bc16d5 | 35 | return number_of_failed_tests; |
AhmedPlaymaker | 68:b9cfd27987ac | 36 | } |
AhmedPlaymaker | 68:b9cfd27987ac | 37 | |
AhmedPlaymaker | 68:b9cfd27987ac | 38 | #endif |