ELEC2645 (2017/18) / Mbed 2 deprecated el17yw

Dependencies:   mbed

boom/boom-test.h

Committer:
RickYu
Date:
2018-04-30
Revision:
29:f3e24ccc401d
Child:
31:e39a1ab1f12d

File content as of revision 29:f3e24ccc401d:

#ifndef BOOM_TEST_H
#define BOOM_TEST_H

/**
check whether the boom will move as x+1,y+1
 */
bool boom_test_movement()
{
    //set the position of boom at(5,8)
    boom boom;
    boom.init(5, 8);

    // get the position
    Vector2D get_pos_1 = boom.get_pos();
    printf("%f, %f\n", get_pos_1.x, get_pos_1.y);


    // Update the position
    boom.update();

    // get the position
    Vector2D get_pos_2 = boom.get_pos();
    printf("%f, %f\n", get_pos_2.x, get_pos_2.y);
    
    bool success_flag = true;
    
    // if the initial position is wrong ,the  test failed
    if (get_pos_1.x != 5 || get_pos_1.y != 8) {
        success_flag = false;
    }
    
    // the test is failed if the boom not go as excepted
    if (get_pos_2.x != 9 || get_pos_2.y != 12) {
        success_flag = false;
    }

    return success_flag;
}
#endif