Skip to content

Commit

Permalink
grid points
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityayadav17 committed Sep 7, 2023
1 parent 4723bd1 commit ebc7366
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ public class GridPoint2Utils {
private GridPoint2Utils() {
throw new IllegalStateException("Instantiating static util class");
}

public static GridPoint2Utils createInstance() {
return new GridPoint2Utils();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.csse3200.game.utils.math;

import com.badlogic.gdx.math.GridPoint2;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class GridPoint2UtilsTest {

/**
* testZero() ensures that GridPoint2Utils.ZERO constant is (0, 0).
* GridPoint2Utils.ZERO is a constant representing the point (0, 0).
*/
@Test
public void testZero() {
GridPoint2 zero = GridPoint2Utils.ZERO;
assertEquals(0, zero.x);
assertEquals(0, zero.y);
}

/**
* testInstantiation() checks if private constructor of GridPoint2Utils throws an exception
* while creating an instance.
*/
@Test
public void testInstantiation() {
assertThrows(IllegalStateException.class, () -> {
GridPoint2Utils.createInstance();
});
}
}

0 comments on commit ebc7366

Please sign in to comment.