From 34185ce286e90dec8f305fdacdcc1c255558b676 Mon Sep 17 00:00:00 2001 From: brendon <36212954+brendonmiranda@users.noreply.github.com> Date: Sat, 12 Oct 2024 19:42:00 +0100 Subject: [PATCH] test aws --- .../java/aws/NumberOfSuitableLocations.java | 2 +- .../aws/NumberOfSuitableLocationsTest.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/test/java/aws/NumberOfSuitableLocationsTest.java diff --git a/src/main/java/aws/NumberOfSuitableLocations.java b/src/main/java/aws/NumberOfSuitableLocations.java index cebe355..8dab106 100644 --- a/src/main/java/aws/NumberOfSuitableLocations.java +++ b/src/main/java/aws/NumberOfSuitableLocations.java @@ -5,7 +5,7 @@ public class NumberOfSuitableLocations { /** * // 2 * abs(x - center[i]) */ - public static int numberOfSuitableLocationsSearch(int[] center, int d) { + public int numberOfSuitableLocationsSearch(int[] center, int d) { long low = -1000000000L; long high = 1000000000L; diff --git a/src/test/java/aws/NumberOfSuitableLocationsTest.java b/src/test/java/aws/NumberOfSuitableLocationsTest.java new file mode 100644 index 0000000..a825fce --- /dev/null +++ b/src/test/java/aws/NumberOfSuitableLocationsTest.java @@ -0,0 +1,18 @@ +package aws; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class NumberOfSuitableLocationsTest { + + @Test + public void test() { + + NumberOfSuitableLocations numberOfSuitableLocations = new NumberOfSuitableLocations(); + Assertions.assertEquals(3,numberOfSuitableLocations.numberOfSuitableLocationsSearch(new int[]{-2, 1, 0}, 8)); + Assertions.assertEquals(5,numberOfSuitableLocations.numberOfSuitableLocationsSearch(new int[]{2, 0, 3, -4}, 22)); + Assertions.assertEquals(0,numberOfSuitableLocations.numberOfSuitableLocationsSearch(new int[]{-3, 2, 2}, 8)); + + } + +}