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.
Fork of fy15raf by
Spaceship-test.h
00001 #ifndef SPACESHIP_TEST_H 00002 #define SPACESHIP_TEST_H 00003 00004 /** 00005 * \brief Check that Spaceship object goes to correct position when it is updated 00006 * 00007 * \returns true if all the tests passed 00008 */ 00009 bool Spaceship_movement() 00010 { 00011 00012 Spaceship S1; 00013 S1.init(); // x= 15 y=(HEIGHT/2) 00014 00015 S1.update(N,2);//set Spaceship to move to the North with magnitude of 2 pixel -> y=(HEIGHT/2) will be changed to y=(HEIGHT/2)-speed and speed=meg*10 00016 00017 Vector2D read_S1_pos = S1.get_pos(); 00018 printf("Spaceship1 position x= %f, y= %f\n", read_S1_pos.x, read_S1_pos.y); //print x and y pos. 00019 00020 bool success_flag = true; 00021 00022 // Fail the test if the position after updating is not equal to the expecting position 00023 if (read_S1_pos.x != 15 || read_S1_pos.y != (HEIGHT/2)-20) { // speed= (2)*10=20 00024 success_flag = false; 00025 } 00026 00027 ///////////////another direction and meg to be tested //////////////////////// 00028 00029 Spaceship S2; 00030 S2.init(); //// x= 15 y=(HEIGHT/2) 00031 00032 S2.update(E,1); //set Spaceship to move toward East with magnitude of 1 pixel -> x=15 will be changed to x=15+speed and speed=meg*10 00033 00034 Vector2D read_S2_pos = S2.get_pos(); 00035 printf("Spaceship2 position x= %f, y= %f\n", read_S2_pos.x, read_S2_pos.y); //print x and y pos. 00036 00037 00038 // Fail the test if the position after updating updating is not equal to the expecting position 00039 if (read_S2_pos.x != 15 +10 || read_S2_pos.y != (HEIGHT/2)) {// speed= (1)*10=10 00040 success_flag = false; 00041 } 00042 00043 return success_flag; 00044 } 00045 #endif
Generated on Thu Jul 14 2022 18:15:41 by
