ELEC2645 (2017/18) / Mbed 2 deprecated ll13jrm

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Snake-test.h Source File

Snake-test.h

00001 #ifndef SNAKE_TEST_H
00002 #define SNAKE_TEST_H
00003 
00004 
00005 /**
00006  * \brief Check that food changes position within game area
00007  * 
00008  * \returns true if all the tests passed
00009  */
00010  
00011   bool snake_test_movement()
00012 {
00013     bool success_flag = true;
00014     
00015     Snake snake; 
00016     
00017     // next diretion test
00018     
00019     snake.set_current_direction(S);
00020     snake.set_snake_direction(N,S);
00021     Direction next = snake.get_snake_direction();
00022     snake.set_snake_position(next);
00023     Vector2D pos = snake.get_snake_position();
00024     
00025     
00026     printf("%c", next);
00027 
00028     printf("Position %f, %f", pos.x, pos.y);
00029     
00030     if(next == !S) {
00031         
00032         success_flag = false;
00033         
00034         }
00035         
00036     if((pos.x != 0) && (pos.y != 1)) {
00037         
00038         success_flag = false;
00039         
00040         }
00041         
00042         return success_flag;
00043        
00044     
00045 }
00046 #endif