Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
tests.h@1:9c7bb3db32bc, 2020-04-22 (annotated)
- Committer:
- ZhongYufan
- Date:
- Wed Apr 22 15:52:04 2020 +0000
- Revision:
- 1:9c7bb3db32bc
- Child:
- 19:08c582bcdc98
claw, gold, winch, monster finished (commit test)
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ZhongYufan | 1:9c7bb3db32bc | 1 | #ifndef TESTS_H |
| ZhongYufan | 1:9c7bb3db32bc | 2 | #define TESTS_H |
| ZhongYufan | 1:9c7bb3db32bc | 3 | |
| ZhongYufan | 1:9c7bb3db32bc | 4 | #include "Claw-test.h" |
| ZhongYufan | 1:9c7bb3db32bc | 5 | |
| ZhongYufan | 1:9c7bb3db32bc | 6 | /** |
| ZhongYufan | 1:9c7bb3db32bc | 7 | * @brief Run all the tests for this program |
| ZhongYufan | 1:9c7bb3db32bc | 8 | * |
| ZhongYufan | 1:9c7bb3db32bc | 9 | * @returns The number of tests that failed |
| ZhongYufan | 1:9c7bb3db32bc | 10 | */ |
| ZhongYufan | 1:9c7bb3db32bc | 11 | int run_all_tests() |
| ZhongYufan | 1:9c7bb3db32bc | 12 | { |
| ZhongYufan | 1:9c7bb3db32bc | 13 | int n_tests_failed = 0; // A log of the number of tests that have failed |
| ZhongYufan | 1:9c7bb3db32bc | 14 | |
| ZhongYufan | 1:9c7bb3db32bc | 15 | // Run the Claw_test_movement test |
| ZhongYufan | 1:9c7bb3db32bc | 16 | printf("Testing Claw_test_movement...\n"); |
| ZhongYufan | 1:9c7bb3db32bc | 17 | bool this_test_passed = Claw_test_movement(); |
| ZhongYufan | 1:9c7bb3db32bc | 18 | |
| ZhongYufan | 1:9c7bb3db32bc | 19 | // Print out the result of this test |
| ZhongYufan | 1:9c7bb3db32bc | 20 | if (this_test_passed) { |
| ZhongYufan | 1:9c7bb3db32bc | 21 | printf("...Passed!\n"); |
| ZhongYufan | 1:9c7bb3db32bc | 22 | } |
| ZhongYufan | 1:9c7bb3db32bc | 23 | else { |
| ZhongYufan | 1:9c7bb3db32bc | 24 | printf("...FAILED!\n"); |
| ZhongYufan | 1:9c7bb3db32bc | 25 | ++n_tests_failed; // Increment number of failures |
| ZhongYufan | 1:9c7bb3db32bc | 26 | } |
| ZhongYufan | 1:9c7bb3db32bc | 27 | |
| ZhongYufan | 1:9c7bb3db32bc | 28 | // Repeat the above for each testing function... |
| ZhongYufan | 1:9c7bb3db32bc | 29 | // ... |
| ZhongYufan | 1:9c7bb3db32bc | 30 | // ... |
| ZhongYufan | 1:9c7bb3db32bc | 31 | |
| ZhongYufan | 1:9c7bb3db32bc | 32 | // Finish by printing a summary of the tests |
| ZhongYufan | 1:9c7bb3db32bc | 33 | if (n_tests_failed > 0) { |
| ZhongYufan | 1:9c7bb3db32bc | 34 | printf("%d tests FAILED!\n", n_tests_failed); |
| ZhongYufan | 1:9c7bb3db32bc | 35 | } |
| ZhongYufan | 1:9c7bb3db32bc | 36 | else { |
| ZhongYufan | 1:9c7bb3db32bc | 37 | printf("All tests passed!\n"); |
| ZhongYufan | 1:9c7bb3db32bc | 38 | } |
| ZhongYufan | 1:9c7bb3db32bc | 39 | |
| ZhongYufan | 1:9c7bb3db32bc | 40 | return n_tests_failed; |
| ZhongYufan | 1:9c7bb3db32bc | 41 | } |
| ZhongYufan | 1:9c7bb3db32bc | 42 | |
| ZhongYufan | 1:9c7bb3db32bc | 43 | #endif |