Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Sat May 04 17:18:44 2019 +0000
Revision:
69:55e309da7efd
Parent:
68:b9cfd27987ac
Child:
74:7b6568bc16d5
fixed a bug where i couldn't see any thing in tutorial class only sometimes by adding an extra lcd.clear();

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 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 68:b9cfd27987ac 13 int n_tests_failed = 0; // A log of the number of tests that have failed
AhmedPlaymaker 68:b9cfd27987ac 14
AhmedPlaymaker 68:b9cfd27987ac 15 // Run the Snake_test_movement test
AhmedPlaymaker 68:b9cfd27987ac 16 printf("Testing Snake_test_movement...\n");
AhmedPlaymaker 68:b9cfd27987ac 17 bool this_test_passed = Snake_test_movement();
AhmedPlaymaker 68:b9cfd27987ac 18
AhmedPlaymaker 68:b9cfd27987ac 19 // Print out the result of this test
AhmedPlaymaker 68:b9cfd27987ac 20 if (this_test_passed) {
AhmedPlaymaker 68:b9cfd27987ac 21 printf("...Passed!\n");
AhmedPlaymaker 69:55e309da7efd 22 } else {
AhmedPlaymaker 68:b9cfd27987ac 23 printf("...FAILED!\n");
AhmedPlaymaker 68:b9cfd27987ac 24 ++n_tests_failed; // Increment number of failures
AhmedPlaymaker 68:b9cfd27987ac 25 }
AhmedPlaymaker 69:55e309da7efd 26
AhmedPlaymaker 68:b9cfd27987ac 27 // Repeat the above for each testing function...
AhmedPlaymaker 68:b9cfd27987ac 28 // ...
AhmedPlaymaker 68:b9cfd27987ac 29 // ...
AhmedPlaymaker 68:b9cfd27987ac 30
AhmedPlaymaker 68:b9cfd27987ac 31 // Finish by printing a summary of the tests
AhmedPlaymaker 68:b9cfd27987ac 32 if (n_tests_failed > 0) {
AhmedPlaymaker 68:b9cfd27987ac 33 printf("%d tests FAILED!\n", n_tests_failed);
AhmedPlaymaker 69:55e309da7efd 34 } else {
AhmedPlaymaker 68:b9cfd27987ac 35 printf("All tests passed!\n");
AhmedPlaymaker 68:b9cfd27987ac 36 }
AhmedPlaymaker 68:b9cfd27987ac 37
AhmedPlaymaker 68:b9cfd27987ac 38 return n_tests_failed;
AhmedPlaymaker 68:b9cfd27987ac 39 }
AhmedPlaymaker 68:b9cfd27987ac 40
AhmedPlaymaker 68:b9cfd27987ac 41 #endif