James Heavey / Mbed 2 deprecated 2665-Breakout-Game

Dependencies:   mbed

Committer:
jamesheavey
Date:
Tue Jan 05 01:14:11 2021 +0000
Revision:
0:92b180c8d407
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jamesheavey 0:92b180c8d407 1 #ifndef TESTS_H
jamesheavey 0:92b180c8d407 2 #define TESTS_H
jamesheavey 0:92b180c8d407 3
jamesheavey 0:92b180c8d407 4 #include "Ball-test.h"
jamesheavey 0:92b180c8d407 5 #include "Brick-test.h"
jamesheavey 0:92b180c8d407 6 #include "Laser-test.h"
jamesheavey 0:92b180c8d407 7
jamesheavey 0:92b180c8d407 8 /**
jamesheavey 0:92b180c8d407 9 * @brief Run unit tests for relevant objects in the Breakout game
jamesheavey 0:92b180c8d407 10 *
jamesheavey 0:92b180c8d407 11 * @returns The number of failed tests
jamesheavey 0:92b180c8d407 12 */
jamesheavey 0:92b180c8d407 13 int run_all_tests()
jamesheavey 0:92b180c8d407 14 {
jamesheavey 0:92b180c8d407 15 int n_tests_failed = 0; // initialised at 0
jamesheavey 0:92b180c8d407 16
jamesheavey 0:92b180c8d407 17 // Run the Ball_test_movement test
jamesheavey 0:92b180c8d407 18 printf("Testing Ball_test_movement...\n");
jamesheavey 0:92b180c8d407 19 bool test_passed1 = Ball_test_movement();
jamesheavey 0:92b180c8d407 20
jamesheavey 0:92b180c8d407 21 // Print out the result of this test
jamesheavey 0:92b180c8d407 22 if (test_passed1) {
jamesheavey 0:92b180c8d407 23 printf("...Passed!\n");
jamesheavey 0:92b180c8d407 24 }
jamesheavey 0:92b180c8d407 25 else {
jamesheavey 0:92b180c8d407 26 printf("...FAILED!\n");
jamesheavey 0:92b180c8d407 27 ++n_tests_failed; // Increment number of failures
jamesheavey 0:92b180c8d407 28 }
jamesheavey 0:92b180c8d407 29
jamesheavey 0:92b180c8d407 30 // Run the Ball_test_movement test
jamesheavey 0:92b180c8d407 31 printf("Testing Brick_test_movement...\n");
jamesheavey 0:92b180c8d407 32 bool test_passed2 = Brick_test_movement();
jamesheavey 0:92b180c8d407 33
jamesheavey 0:92b180c8d407 34 // Print out the result of this test
jamesheavey 0:92b180c8d407 35 if (test_passed2) {
jamesheavey 0:92b180c8d407 36 printf("...Passed!\n");
jamesheavey 0:92b180c8d407 37 }
jamesheavey 0:92b180c8d407 38 else {
jamesheavey 0:92b180c8d407 39 printf("...FAILED!\n");
jamesheavey 0:92b180c8d407 40 ++n_tests_failed; // Increment number of failures
jamesheavey 0:92b180c8d407 41 }
jamesheavey 0:92b180c8d407 42
jamesheavey 0:92b180c8d407 43 // Run the Ball_test_movement test
jamesheavey 0:92b180c8d407 44 printf("Testing Laser_test_movement...\n");
jamesheavey 0:92b180c8d407 45 bool test_passed3 = Laser_test_movement();
jamesheavey 0:92b180c8d407 46
jamesheavey 0:92b180c8d407 47 // Print out the result of this test
jamesheavey 0:92b180c8d407 48 if (test_passed3) {
jamesheavey 0:92b180c8d407 49 printf("...Passed!\n");
jamesheavey 0:92b180c8d407 50 }
jamesheavey 0:92b180c8d407 51 else {
jamesheavey 0:92b180c8d407 52 printf("...FAILED!\n");
jamesheavey 0:92b180c8d407 53 ++n_tests_failed; // Increment number of failures
jamesheavey 0:92b180c8d407 54 }
jamesheavey 0:92b180c8d407 55
jamesheavey 0:92b180c8d407 56 // Finish by printing a summary of the tests
jamesheavey 0:92b180c8d407 57 if (n_tests_failed > 0) {
jamesheavey 0:92b180c8d407 58 printf("%d tests FAILED!\n", n_tests_failed);
jamesheavey 0:92b180c8d407 59 }
jamesheavey 0:92b180c8d407 60 else {
jamesheavey 0:92b180c8d407 61 printf("All tests passed!\n");
jamesheavey 0:92b180c8d407 62 }
jamesheavey 0:92b180c8d407 63
jamesheavey 0:92b180c8d407 64 return n_tests_failed;
jamesheavey 0:92b180c8d407 65 }
jamesheavey 0:92b180c8d407 66
jamesheavey 0:92b180c8d407 67 #endif