ELEC2645 (2017/18) / Mbed 2 deprecated ll13jrm

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tests.h Source File

tests.h

00001 #ifndef TESTS_H
00002 #define TESTS_H
00003 
00004 #include "Food-test.h"
00005 #include "Snake-test.h"
00006 
00007 /**
00008 * @brief Runs tests on Food, Snake, and SnakeEngine classes
00009 * @return Returns number of tests failed
00010 */
00011 
00012 
00013 int run_tests()
00014 {
00015     
00016     int tests_failed = 0; // number of failed tests
00017     
00018     // run food position tests
00019     
00020     printf("Running Food Positions Tests \n");
00021     
00022     bool food_test_passed = food_test_position();
00023     bool snake_test_passed = snake_test_movement();
00024     
00025     if(food_test_passed) {
00026         
00027         printf("FOOD TEST PASSED \n");
00028         
00029         }
00030         
00031         else {
00032             
00033             printf("FOOD TEST FAILED \n");
00034             
00035             ++tests_failed;
00036             
00037             }
00038     
00039     if(snake_test_passed) {
00040         
00041         printf("SNAKE TEST PASSED \n");
00042         
00043         }
00044         
00045         else {
00046             
00047             printf("SNAKE TEST FAILED \n");
00048             
00049             ++tests_failed;
00050             
00051             }
00052         
00053             
00054         
00055         
00056         // print how many tests failed or all passed
00057         
00058         if(tests_failed > 0) {
00059             
00060             printf("%i tests failed \n", tests_failed);
00061             
00062             }
00063             
00064             else {
00065                 
00066                 
00067                 printf("All passed");
00068                 
00069                 }
00070                 
00071         return tests_failed;
00072             
00073 }
00074             
00075             
00076     
00077 
00078 
00079 #endif