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.
Diff: Map/Map_test.h
- Revision:
- 14:7419c680656f
- Parent:
- 13:12276eed13ac
- Child:
- 15:90b6821bcf64
diff -r 12276eed13ac -r 7419c680656f Map/Map_test.h
--- a/Map/Map_test.h Sun Apr 26 17:08:10 2020 +0000
+++ b/Map/Map_test.h Sun Apr 26 20:31:53 2020 +0000
@@ -4,51 +4,41 @@
// Objects reqired for test ----------------------------------------------------
Gamepad pad;
N5110 lcd;
-Spaceship spaceship;
Map map;
/** Map Test
-@brief Checks map goes to the correct postion when moved
+@brief Checks that the map goes to the correct x postion when moved.
@author Benjamin Evans, University of Leeds
@date April 2020
@return true if test are passed
*/
-bool map_draw_test(){
- // Objects reqired for test
- Serial usb(USBTX, USBRX);
-
- // Flag to return if test passed
- bool pass_flag = true;
+bool map_move_test(int move_map, int expected_x_position){
+ // Objects reqired for test ------------------------------------------------
+ Gamepad pad;
+ Map map;
- // Initialise map in start postion of -84, 42 and draw
- lcd.init();
- map.init(adc);
- map.draw_map(lcd,0);
+ // Initialise map in start postion of -84,42
+ pad.init();
+ map.init(pad);
- // Reads start spaceship postion
- int start_x_postion = map.get_position_x_map();
- usb.printf("start postion x = %d\n", start_x_postion);
+ printf("move map = %d : ", move_map);
-// Test drap map function
- map.draw_map(lcd,1);
+ // Draws map but with move variable set so it starts above 0
+ // As can't rea pixel of the LCD
+ map.draw_map(lcd, move_map);
- // Reads end map position
- int end_x_postion_one = map.get_position_x_map();
- usb.printf("end postion one x = %d\n", end_x_postion_one );
-
- //TO check if map moves in opsite direction
- map.draw_map(lcd,-1);
+ //Reads start postion of map drawn
+ int map_start_draw_postion = map.get_position_x_map();
- // Reads end map position
- int end_x_postion_two = map.get_position_x_map();
- usb.printf("end postion two x = %d\n", end_x_postion_two );
-
- // Fail test if start postision is incorrect
- if (end_x_postion_one != -83 || end_x_postion_two != -84) {
- pass_flag = false;
+ // Checks final position with espected
+ if (map_start_draw_postion == expected_x_position) {
+ printf ( "Passed!\n");
+ return true;
+ } else {
+ printf ( "Failed! value = %d, (expecting %d)\n",map_start_draw_postion, expected_x_position);
+ return false;
}
+}
- return pass_flag;
-}
#endif
\ No newline at end of file