
yumaowei 201377547
Dependencies: mbed ELEC2645_Project_el17my
tests.h@2:5e54476c518f, 2020-05-26 (annotated)
- Committer:
- yumaowei
- Date:
- Tue May 26 07:24:21 2020 +0000
- Revision:
- 2:5e54476c518f
Final Submission. I have read and agreed with Statement of Academic Integrity.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yumaowei | 2:5e54476c518f | 1 | #ifndef TESTS_H |
yumaowei | 2:5e54476c518f | 2 | #define TESTS_H |
yumaowei | 2:5e54476c518f | 3 | |
yumaowei | 2:5e54476c518f | 4 | #include "Ball-test.h" |
yumaowei | 2:5e54476c518f | 5 | |
yumaowei | 2:5e54476c518f | 6 | /** |
yumaowei | 2:5e54476c518f | 7 | * @brief Run all the tests for this program |
yumaowei | 2:5e54476c518f | 8 | * |
yumaowei | 2:5e54476c518f | 9 | * @returns The number of tests that failed |
yumaowei | 2:5e54476c518f | 10 | */ |
yumaowei | 2:5e54476c518f | 11 | int run_all_tests() |
yumaowei | 2:5e54476c518f | 12 | { |
yumaowei | 2:5e54476c518f | 13 | int n_tests_failed = 0; // A log of the number of tests that have failed |
yumaowei | 2:5e54476c518f | 14 | |
yumaowei | 2:5e54476c518f | 15 | // Run the Ball_test_movement test |
yumaowei | 2:5e54476c518f | 16 | printf("Testing Ball_test_movement...\n"); |
yumaowei | 2:5e54476c518f | 17 | bool this_test_passed = Ball_test_movement(); |
yumaowei | 2:5e54476c518f | 18 | |
yumaowei | 2:5e54476c518f | 19 | // Print out the result of this test |
yumaowei | 2:5e54476c518f | 20 | if (this_test_passed) { |
yumaowei | 2:5e54476c518f | 21 | printf("...Passed!\n"); |
yumaowei | 2:5e54476c518f | 22 | } |
yumaowei | 2:5e54476c518f | 23 | else { |
yumaowei | 2:5e54476c518f | 24 | printf("...FAILED!\n"); |
yumaowei | 2:5e54476c518f | 25 | ++n_tests_failed; // Increment number of failures |
yumaowei | 2:5e54476c518f | 26 | } |
yumaowei | 2:5e54476c518f | 27 | |
yumaowei | 2:5e54476c518f | 28 | // Repeat the above for each testing function... |
yumaowei | 2:5e54476c518f | 29 | // ... |
yumaowei | 2:5e54476c518f | 30 | // ... |
yumaowei | 2:5e54476c518f | 31 | |
yumaowei | 2:5e54476c518f | 32 | // Finish by printing a summary of the tests |
yumaowei | 2:5e54476c518f | 33 | if (n_tests_failed > 0) { |
yumaowei | 2:5e54476c518f | 34 | printf("%d tests FAILED!\n", n_tests_failed); |
yumaowei | 2:5e54476c518f | 35 | } |
yumaowei | 2:5e54476c518f | 36 | else { |
yumaowei | 2:5e54476c518f | 37 | printf("All tests passed!\n"); |
yumaowei | 2:5e54476c518f | 38 | } |
yumaowei | 2:5e54476c518f | 39 | |
yumaowei | 2:5e54476c518f | 40 | return n_tests_failed; |
yumaowei | 2:5e54476c518f | 41 | } |
yumaowei | 2:5e54476c518f | 42 | |
yumaowei | 2:5e54476c518f | 43 | #endif |