Wang Lin 201090174

Dependencies:   mbed Gamepad N5110 FXOS8700Q

Committer:
valavanisalex
Date:
Tue Apr 17 08:00:08 2018 +0000
Revision:
11:1447cb7dce3c
Parent:
10:167d0aa1c9b3
Correct type error and add documentation

Who changed what in which revision?

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