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.
Dependencies: mbed
People-test.h
00001 #ifndef PEOPLE_TEST_H 00002 #define PEOPLE_TEST_H 00003 00004 /** PEOPEL(main object) test 00005 *@brief Check the initial position and whether people goes to correct position when moved 00006 *@author Zeyu Feng 00007 *@date 10 May 2020 00008 *@returns true if all the tests passed 00009 */ 00010 00011 bool People_test() 00012 { 00013 //initialise people object 00014 People people; 00015 people.init(); 00016 00017 //Set the postion to 10,10 00018 Vector2D initial_pos = {10,10}; 00019 people.set_pos(initial_pos); 00020 00021 //read initial position 00022 Vector2D pos_init = people.get_pos(); 00023 00024 //first test 00025 //set the velocity 00026 people.set_velocity(S,0.4); 00027 00028 //update position(10,12) 00029 people.update(); 00030 00031 //read test position 00032 Vector2D pos_test1 = people.get_pos(); 00033 //printf("test_pos1 = %f,%f\n",pos_test1.x,pos_test1.y); 00034 00035 //second test 00036 people.set_velocity(NW,0.9); 00037 00038 //update position(6,8) 00039 people.update(); 00040 00041 Vector2D pos_test2 = people.get_pos(); 00042 //printf("test_pos2 = %f,%f\n",pos_test2.x,pos_test2.y); 00043 00044 //Check the position 00045 bool success_flag = true; 00046 if (pos_init.x !=10|| pos_init.y!=10|| 00047 pos_test1.x!=10||pos_test1.y!=12|| 00048 pos_test2.x!=6 ||pos_test2.y!=8) 00049 success_flag = false; 00050 00051 return success_flag; 00052 } 00053 #endif 00054 00055
Generated on Thu Jul 14 2022 12:45:25 by
