Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Thu May 09 10:10:10 2019 +0000
Revision:
99:4841f326200f
Parent:
74:7b6568bc16d5
Child:
103:64bc823d71f4
added file documentation lines to non classes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AhmedPlaymaker 68:b9cfd27987ac 1 #ifndef TESTS_H
AhmedPlaymaker 68:b9cfd27987ac 2 #define TESTS_H
AhmedPlaymaker 68:b9cfd27987ac 3
AhmedPlaymaker 99:4841f326200f 4 /** @file Tests.h
AhmedPlaymaker 99:4841f326200f 5 * @brief Used to call Snake-test.h and check the results of the tests performed.
AhmedPlaymaker 99:4841f326200f 6 */
AhmedPlaymaker 99:4841f326200f 7
AhmedPlaymaker 68:b9cfd27987ac 8 #include "Snake-test.h"
AhmedPlaymaker 68:b9cfd27987ac 9
AhmedPlaymaker 68:b9cfd27987ac 10 /**
AhmedPlaymaker 68:b9cfd27987ac 11 * @brief Run all the tests for this program
AhmedPlaymaker 68:b9cfd27987ac 12 *
AhmedPlaymaker 68:b9cfd27987ac 13 * @returns The number of tests that failed
AhmedPlaymaker 68:b9cfd27987ac 14 */
AhmedPlaymaker 68:b9cfd27987ac 15 int run_all_tests()
AhmedPlaymaker 68:b9cfd27987ac 16 {
AhmedPlaymaker 74:7b6568bc16d5 17 int number_of_failed_tests = 0; // A log of the number of tests that have failed
AhmedPlaymaker 68:b9cfd27987ac 18
AhmedPlaymaker 74:7b6568bc16d5 19 // Run the Snake_test_movement
AhmedPlaymaker 68:b9cfd27987ac 20 printf("Testing Snake_test_movement...\n");
AhmedPlaymaker 74:7b6568bc16d5 21 bool snake_movement_test_passed = Snake_test_movement();
AhmedPlaymaker 68:b9cfd27987ac 22
AhmedPlaymaker 68:b9cfd27987ac 23 // Print out the result of this test
AhmedPlaymaker 74:7b6568bc16d5 24 if (snake_movement_test_passed) {
AhmedPlaymaker 74:7b6568bc16d5 25 printf("...Passed!, no worries the game is alright\n");
AhmedPlaymaker 69:55e309da7efd 26 } else {
AhmedPlaymaker 68:b9cfd27987ac 27 printf("...FAILED!\n");
AhmedPlaymaker 74:7b6568bc16d5 28 ++number_of_failed_tests; // Increment number of failures
AhmedPlaymaker 68:b9cfd27987ac 29 }
AhmedPlaymaker 69:55e309da7efd 30
AhmedPlaymaker 68:b9cfd27987ac 31
AhmedPlaymaker 68:b9cfd27987ac 32 // Finish by printing a summary of the tests
AhmedPlaymaker 74:7b6568bc16d5 33 if (number_of_failed_tests > 0) {
AhmedPlaymaker 74:7b6568bc16d5 34 printf("%d tests FAILED!\n", number_of_failed_tests);
AhmedPlaymaker 69:55e309da7efd 35 } else {
AhmedPlaymaker 68:b9cfd27987ac 36 printf("All tests passed!\n");
AhmedPlaymaker 68:b9cfd27987ac 37 }
AhmedPlaymaker 68:b9cfd27987ac 38
AhmedPlaymaker 74:7b6568bc16d5 39 return number_of_failed_tests;
AhmedPlaymaker 68:b9cfd27987ac 40 }
AhmedPlaymaker 68:b9cfd27987ac 41
AhmedPlaymaker 68:b9cfd27987ac 42 #endif