James Heavey
/
EL17JH
FINAL VERSION
Embed:
(wiki syntax)
Show/hide line numbers
Laser-test.h
00001 #ifndef LASER_TEST_H 00002 #define LASER_TEST_H 00003 00004 /** 00005 * \brief Check that Laser object goes to correct position when moved 00006 * 00007 * \returns true if all the tests passed 00008 */ 00009 bool Laser_test_movement() 00010 { 00011 // Initialise Laser object at -10,0 with velocity of y as -2 00012 Laser _laser; 00013 _laser.init(); 00014 00015 int read_pos1x = _laser.get_x(); 00016 int read_pos1y = _laser.get_y(); 00017 00018 // Read the position 00019 printf("%f, %f\n", read_pos1x, read_pos1y); 00020 00021 // Set the x position to 10, 0 00022 _laser.set_posx(10); 00023 00024 // Update the position 00025 _laser.update(); 00026 00027 int read_pos2x = _laser.get_x(); 00028 int read_pos2y = _laser.get_y(); 00029 00030 // Read the position 00031 printf("%f, %f\n", read_pos2x, read_pos2y); 00032 00033 // Now check that both the positions are as expected 00034 bool success_flag = true; 00035 00036 // Fail the test if the initial position is wrong 00037 if (read_pos1x != 0 || read_pos1y != 0) { 00038 success_flag = false; 00039 } 00040 if (read_pos2x != 10 || read_pos2y != 0) { 00041 success_flag = false; 00042 } 00043 00044 00045 00046 return success_flag; 00047 } 00048 #endif
Generated on Thu Jul 14 2022 01:22:29 by 1.7.2