Browse Source

Added test for isWithin Function in Vector2

remotes/origin/menu
Julian 11 months ago
parent
commit
8f845460cc
  1. 38
      src/test/java/pacmanTests/Vector2Test.java

38
src/test/java/pacmanTests/Vector2Test.java

@ -45,7 +45,7 @@ class Vector2Test {
// assert // assert
assertThat(expected).isEqualTo(result); assertThat(expected).isEqualTo(result);
} }
@Test @Test
void Vector2_clone_createsClone() { void Vector2_clone_createsClone() {
// arrange // arrange
@ -57,4 +57,40 @@ class Vector2Test {
// assert // assert
assertThat(clone).isEqualTo(comparator); assertThat(clone).isEqualTo(comparator);
} }
@Test
void Vector2_isWithin_returnsTrueWhenWithin() {
// arrange
Vector2 area = new Vector2(30, 30);
Vector2 point = new Vector2(2, 8);
// act
boolean isWithin = point.isWithin(area);
boolean expectedWithin = true;
// assert
assertThat(isWithin).isEqualTo(expectedWithin);
}
@Test
void Vector2_isWithin_returnsFalseWhenOutside() {
// arrange
Vector2 area = new Vector2(30, 30);
Vector2 point = new Vector2(53, 8);
// act
boolean isWithin = point.isWithin(area);
boolean expectedWithin = false;
// assert
assertThat(isWithin).isEqualTo(expectedWithin);
}
@Test
void Vector2_isWithin_returnsFalseOnEqual() {
// arrange
Vector2 area = new Vector2(30, 30);
Vector2 point = new Vector2(30, 15);
// act
boolean isWithin = point.isWithin(area);
boolean expectedWithin = false;
// assert
assertThat(isWithin).isEqualTo(expectedWithin);
}
} }
Loading…
Cancel
Save