Skip to content

Commit

Permalink
First draft ui_movement test
Browse files Browse the repository at this point in the history
  • Loading branch information
MicheleMichetti committed Mar 3, 2024
1 parent adb3773 commit a8ad6cf
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions tests/unit-tests/ui_Movement.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include<Movement.hpp>
#include "gtest/gtest.h"

using namespace _movement;

utils::Coordinate coordinate;
uint8_t direction;

Expand All @@ -10,14 +12,40 @@ void resetState() {
direction = utils::Direction::none;
}

int movingUp(int numberOfSteps) {
bool movingUp(int numberOfSteps) {

resetState();

//_movement::Movement myMovement(coordinate, direction);
Movement my_movement(coordinate, direction);
my_movement.moveUp();
utils::Coordinate updated_coordinates = my_movement.getCoordinate();
uint8_t updated_direction = my_movement.getDirection();
utils::Coordinate updated_future_coordinates = my_movement.getFutureCoordinate();
uint8_t updated_future_direction = my_movement.getFutureDirection();


bool result_x = false;
if(updated_coordinates.x == updated_future_coordinates.x) {
result_x == true;
}
bool result_y = false;
if( (updated_coordinates.y+1) == updated_future_coordinates.y) {
result_y == true;
}
bool result_direction = false;
if(updated_direction == utils::Direction::none && updated_future_direction == utils::Direction::up) {
result_direction == true;
}

return result_x & result_y & result_direction;

resetState();

}

namespace {

TEST() {
EXPECT_EQ(true, movingUp(1));
}

}

0 comments on commit a8ad6cf

Please sign in to comment.