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@39:dfc489594f11, 2019-05-09 (annotated)
- Committer:
- JamesCummins
- Date:
- Thu May 09 01:58:36 2019 +0000
- Revision:
- 39:dfc489594f11
- Child:
- 40:a1cdb6ab08af
Added test benches and included in main. Think I'm now all finished. Will check everything and produce final commit tomorrow morning
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JamesCummins | 39:dfc489594f11 | 1 | #ifndef TESTS_H |
JamesCummins | 39:dfc489594f11 | 2 | #define TESTS_H |
JamesCummins | 39:dfc489594f11 | 3 | |
JamesCummins | 39:dfc489594f11 | 4 | #include "ball_test.h" |
JamesCummins | 39:dfc489594f11 | 5 | #include "map_test.h" |
JamesCummins | 39:dfc489594f11 | 6 | |
JamesCummins | 39:dfc489594f11 | 7 | /** Tests |
JamesCummins | 39:dfc489594f11 | 8 | @brief Runs all tests for the Labyrinth game |
JamesCummins | 39:dfc489594f11 | 9 | @returns The total number of failures in the testbenches |
JamesCummins | 39:dfc489594f11 | 10 | */ |
JamesCummins | 39:dfc489594f11 | 11 | |
JamesCummins | 39:dfc489594f11 | 12 | int no_of_tests_failed(){ |
JamesCummins | 39:dfc489594f11 | 13 | //initialise failures to 0 |
JamesCummins | 39:dfc489594f11 | 14 | int quantity_failed = 0; |
JamesCummins | 39:dfc489594f11 | 15 | //run ball test |
JamesCummins | 39:dfc489594f11 | 16 | printf("Testing ball movement:\n"); |
JamesCummins | 39:dfc489594f11 | 17 | bool balltest = ball_test(); |
JamesCummins | 39:dfc489594f11 | 18 | //print results to terminal and increment failure count if failed |
JamesCummins | 39:dfc489594f11 | 19 | if(balltest){ printf("Ball test passed.\n"); } |
JamesCummins | 39:dfc489594f11 | 20 | else if (!(balltest)){ |
JamesCummins | 39:dfc489594f11 | 21 | printf("Ball test failed!\n"); |
JamesCummins | 39:dfc489594f11 | 22 | quantity_failed++; |
JamesCummins | 39:dfc489594f11 | 23 | } |
JamesCummins | 39:dfc489594f11 | 24 | //run map test |
JamesCummins | 39:dfc489594f11 | 25 | printf("Testing map pixel reading:\n"); |
JamesCummins | 39:dfc489594f11 | 26 | bool maptest = map_test(); |
JamesCummins | 39:dfc489594f11 | 27 | //print results to terminal and increment failure count if failed |
JamesCummins | 39:dfc489594f11 | 28 | if(maptest) {printf("Map test passed.\n"); } |
JamesCummins | 39:dfc489594f11 | 29 | else if (!(maptest)){ |
JamesCummins | 39:dfc489594f11 | 30 | printf("Map test failed!\n"); |
JamesCummins | 39:dfc489594f11 | 31 | quantity_failed++; |
JamesCummins | 39:dfc489594f11 | 32 | } |
JamesCummins | 39:dfc489594f11 | 33 | //Summary of results printed to terminal |
JamesCummins | 39:dfc489594f11 | 34 | printf ("Total tests failed = %d\n", quantity_failed); |
JamesCummins | 39:dfc489594f11 | 35 | |
JamesCummins | 39:dfc489594f11 | 36 | return quantity_failed; |
JamesCummins | 39:dfc489594f11 | 37 | } |
JamesCummins | 39:dfc489594f11 | 38 | #endif |