Pong for Gamepad2

Dependencies:   mbed

Edit.

Committer:
eencae
Date:
Fri Jan 31 12:32:38 2020 +0000
Revision:
0:7423345f87c5
Pong ported to Gamepad2;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eencae 0:7423345f87c5 1 #ifndef TESTS_H
eencae 0:7423345f87c5 2 #define TESTS_H
eencae 0:7423345f87c5 3
eencae 0:7423345f87c5 4 #include "Ball-test.h"
eencae 0:7423345f87c5 5
eencae 0:7423345f87c5 6 /**
eencae 0:7423345f87c5 7 * @brief Run all the tests for this program
eencae 0:7423345f87c5 8 *
eencae 0:7423345f87c5 9 * @returns The number of tests that failed
eencae 0:7423345f87c5 10 */
eencae 0:7423345f87c5 11 int run_all_tests()
eencae 0:7423345f87c5 12 {
eencae 0:7423345f87c5 13 int n_tests_failed = 0; // A log of the number of tests that have failed
eencae 0:7423345f87c5 14
eencae 0:7423345f87c5 15 // Run the Ball_test_movement test
eencae 0:7423345f87c5 16 printf("Testing Ball_test_movement...\n");
eencae 0:7423345f87c5 17 bool this_test_passed = Ball_test_movement();
eencae 0:7423345f87c5 18
eencae 0:7423345f87c5 19 // Print out the result of this test
eencae 0:7423345f87c5 20 if (this_test_passed) {
eencae 0:7423345f87c5 21 printf("...Passed!\n");
eencae 0:7423345f87c5 22 }
eencae 0:7423345f87c5 23 else {
eencae 0:7423345f87c5 24 printf("...FAILED!\n");
eencae 0:7423345f87c5 25 ++n_tests_failed; // Increment number of failures
eencae 0:7423345f87c5 26 }
eencae 0:7423345f87c5 27
eencae 0:7423345f87c5 28 // Repeat the above for each testing function...
eencae 0:7423345f87c5 29 // ...
eencae 0:7423345f87c5 30 // ...
eencae 0:7423345f87c5 31
eencae 0:7423345f87c5 32 // Finish by printing a summary of the tests
eencae 0:7423345f87c5 33 if (n_tests_failed > 0) {
eencae 0:7423345f87c5 34 printf("%d tests FAILED!\n", n_tests_failed);
eencae 0:7423345f87c5 35 }
eencae 0:7423345f87c5 36 else {
eencae 0:7423345f87c5 37 printf("All tests passed!\n");
eencae 0:7423345f87c5 38 }
eencae 0:7423345f87c5 39
eencae 0:7423345f87c5 40 return n_tests_failed;
eencae 0:7423345f87c5 41 }
eencae 0:7423345f87c5 42
eencae 0:7423345f87c5 43 #endif