Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Thu May 09 14:52:19 2019 +0000
Revision:
104:17040265b7b4
Parent:
103:64bc823d71f4
Final Submission. I have read and agreed with Statement of Academic Integrity.

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