Zikang Qian / Mbed 2 deprecated el17z2q

Dependencies:   mbed

Fork of el17z2q by ELEC2645 (2017/18)

Committer:
yzjdxl
Date:
Mon May 07 22:11:43 2018 +0000
Branch:
GameEngine
Revision:
2:6dc7bc55c1cb
Parent:
1:00a4ea97c4cd
publish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yzjdxl 1:00a4ea97c4cd 1 #ifndef TESTS_H
yzjdxl 1:00a4ea97c4cd 2 #define TESTS_H
yzjdxl 1:00a4ea97c4cd 3
yzjdxl 1:00a4ea97c4cd 4 #include "Coin-test.h"
yzjdxl 1:00a4ea97c4cd 5 #include "Hscore-test.h"
yzjdxl 1:00a4ea97c4cd 6 #include "CoinWithBag-test.h"
yzjdxl 1:00a4ea97c4cd 7 #include "CoinWithBoundary-test.h"
yzjdxl 1:00a4ea97c4cd 8
yzjdxl 1:00a4ea97c4cd 9 /**
yzjdxl 1:00a4ea97c4cd 10 * @brief Run all the tests for this program
yzjdxl 1:00a4ea97c4cd 11 *
yzjdxl 1:00a4ea97c4cd 12 * @returns The number of tests that failed
yzjdxl 1:00a4ea97c4cd 13 */
yzjdxl 1:00a4ea97c4cd 14 int run_all_tests()
yzjdxl 1:00a4ea97c4cd 15 {
yzjdxl 1:00a4ea97c4cd 16 int n_tests_failed = 0; // A log of the number of tests that have failed
yzjdxl 1:00a4ea97c4cd 17
yzjdxl 1:00a4ea97c4cd 18 // Run the Ball_test_movement test
yzjdxl 1:00a4ea97c4cd 19 printf("Testing Coin_test_movement...\n");
yzjdxl 1:00a4ea97c4cd 20 bool test1_passed = Coin_test_movement();
yzjdxl 1:00a4ea97c4cd 21
yzjdxl 1:00a4ea97c4cd 22 printf("Testing GetHscore_test_value...\n");
yzjdxl 1:00a4ea97c4cd 23 bool test2_passed = GetHscore_test_value();
yzjdxl 1:00a4ea97c4cd 24
yzjdxl 1:00a4ea97c4cd 25 printf("Testing CoinWithBag_test_collide...\n");
yzjdxl 1:00a4ea97c4cd 26 bool test3_passed = CoinWithBag_test_collide();
yzjdxl 1:00a4ea97c4cd 27
yzjdxl 1:00a4ea97c4cd 28 printf("Testing CoinWithBoundary_test_collide...\n");
yzjdxl 1:00a4ea97c4cd 29 bool test4_passed = CoinWithBoundary_test_collide();
yzjdxl 1:00a4ea97c4cd 30
yzjdxl 1:00a4ea97c4cd 31 // Print out the result of this test
yzjdxl 1:00a4ea97c4cd 32 if (test1_passed) {
yzjdxl 1:00a4ea97c4cd 33 printf("...Passed!\n");
yzjdxl 1:00a4ea97c4cd 34 }
yzjdxl 1:00a4ea97c4cd 35 else {
yzjdxl 1:00a4ea97c4cd 36 printf("...Failed!\n");
yzjdxl 1:00a4ea97c4cd 37 ++n_tests_failed; // Increment number of failures
yzjdxl 1:00a4ea97c4cd 38 }
yzjdxl 1:00a4ea97c4cd 39 if (test2_passed) {
yzjdxl 1:00a4ea97c4cd 40 printf("...Passed!\n");
yzjdxl 1:00a4ea97c4cd 41 }
yzjdxl 1:00a4ea97c4cd 42 else {
yzjdxl 1:00a4ea97c4cd 43 printf("...Failed!\n");
yzjdxl 1:00a4ea97c4cd 44 ++n_tests_failed; // Increment number of failures
yzjdxl 1:00a4ea97c4cd 45 }
yzjdxl 1:00a4ea97c4cd 46 if (test3_passed) {
yzjdxl 1:00a4ea97c4cd 47 printf("...Passed!\n");
yzjdxl 1:00a4ea97c4cd 48 }
yzjdxl 1:00a4ea97c4cd 49 else {
yzjdxl 1:00a4ea97c4cd 50 printf("...Failed!\n");
yzjdxl 1:00a4ea97c4cd 51 ++n_tests_failed; // Increment number of failures
yzjdxl 1:00a4ea97c4cd 52 }
yzjdxl 1:00a4ea97c4cd 53 if (test4_passed) {
yzjdxl 1:00a4ea97c4cd 54 printf("...Passed!\n");
yzjdxl 1:00a4ea97c4cd 55 }
yzjdxl 1:00a4ea97c4cd 56 else {
yzjdxl 1:00a4ea97c4cd 57 printf("...Failed!\n");
yzjdxl 1:00a4ea97c4cd 58 ++n_tests_failed; // Increment number of failures
yzjdxl 1:00a4ea97c4cd 59 }
yzjdxl 1:00a4ea97c4cd 60
yzjdxl 1:00a4ea97c4cd 61 // Finish by printing a summary of the tests
yzjdxl 1:00a4ea97c4cd 62 if (n_tests_failed > 0) {
yzjdxl 1:00a4ea97c4cd 63 printf("%d tests FAILED!\n", n_tests_failed);
yzjdxl 1:00a4ea97c4cd 64 }
yzjdxl 1:00a4ea97c4cd 65 else {
yzjdxl 1:00a4ea97c4cd 66 printf("All tests passed!\n");
yzjdxl 1:00a4ea97c4cd 67 }
yzjdxl 1:00a4ea97c4cd 68
yzjdxl 1:00a4ea97c4cd 69 return n_tests_failed;
yzjdxl 1:00a4ea97c4cd 70 }
yzjdxl 1:00a4ea97c4cd 71
yzjdxl 1:00a4ea97c4cd 72 #endif