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.
ball_test.h
00001 #ifndef BALL_TEST_H 00002 #define BALL_TEST_H 00003 00004 /** Ball Test 00005 @brief Check that the ball moves as it should without seeding by the accelerometer 00006 @returns true if moves correctly, false if moves incorrectly 00007 */ 00008 00009 bool ball_test(){ 00010 Ball ball; //create ball object 00011 ball.init(3); //set radius to 3 00012 Vector2D ball_pos = {10, 20}; //give ball initial position of (10,20) 00013 ball.set_position(ball_pos); 00014 Vector2D ball_vel = {3, -5}; //give ball initial velocity of (3, -5) 00015 ball.set_velocity(ball_vel); 00016 ball.update(); //update ball position 00017 ball_pos = ball.get_position(); 00018 00019 bool passed = true; 00020 if(ball_pos.x != 13){ passed = false; } //check whether ball in correct position 00021 else if(ball_pos.y != 15){ passed = false; } //return false if not 00022 else { passed = true; } 00023 return passed; 00024 } 00025 00026 #endif
Generated on Thu Jul 14 2022 00:39:27 by
1.7.2