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