diff --git a/pom.xml b/pom.xml
index 4d1101e..d469778 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,4 +14,26 @@
UTF-8
+
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.11.4
+ test
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.5.2
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/java/TestPartitions.java b/src/test/java/TestPartitions.java
new file mode 100644
index 0000000..0f489ae
--- /dev/null
+++ b/src/test/java/TestPartitions.java
@@ -0,0 +1,65 @@
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+
+public class TestPartitions {
+ static Exercises ex;
+
+ @BeforeAll
+ static void setUp() {
+ ex = new Exercises();
+ }
+
+ @Test
+ void testPartition0() {
+ int[][] expected = {
+ {1}
+ };
+ assertArrayEquals(expected, ex.intPartitions(1));
+ }
+
+ @Test
+ void testPartition1() {
+ int[][] expected = {
+ {4},
+ {3, 1},
+ {2, 2},
+ {2, 1, 1},
+ {1, 1, 1, 1}
+ };
+ assertArrayEquals(expected, ex.intPartitions(4));
+ }
+
+ @Test
+ void testPartition2() {
+ int[][] expected = {
+ {5},
+ {4, 1},
+ {3, 2},
+ {3, 1, 1},
+ {2, 2, 1},
+ {2, 1, 1, 1},
+ {1, 1, 1, 1, 1}
+ };
+ assertArrayEquals(expected, ex.intPartitions(5));
+ }
+
+ @Test
+ void testPartition3() {
+ int[][] expected = {
+ {6},
+ {5, 1},
+ {4, 2},
+ {4, 1, 1},
+ {3, 3},
+ {3, 2, 1},
+ {3, 1, 1, 1},
+ {2, 2, 2},
+ {2, 2, 1, 1},
+ {2, 1, 1, 1, 1},
+ {1, 1, 1, 1, 1, 1}
+ };
+ assertArrayEquals(expected, ex.intPartitions(6));
+ }
+}
diff --git a/src/test/java/TestTraversal.java b/src/test/java/TestTraversal.java
new file mode 100644
index 0000000..2255c50
--- /dev/null
+++ b/src/test/java/TestTraversal.java
@@ -0,0 +1,66 @@
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+
+public class TestTraversal {
+ static Exercises ex;
+
+ @BeforeAll
+ static void setUp() {
+ ex = new Exercises();
+ }
+
+ @Test
+ void testTraverse0() {
+ int[][] nums = {
+ {1, 2, 3, 4, 5}
+ };
+ int rows = 1;
+ int cols = 5;
+ int[] expected = {1, 2, 3, 4, 5};
+ assertArrayEquals(expected, ex.spiralTraversal(nums, rows, cols));
+ }
+
+ @Test
+ void testTraverse1() {
+ int[][] nums = {
+ {1, 2, 3},
+ {4, 5, 6},
+ {7, 8, 9},
+ {10, 11, 12}
+ };
+ int rows = 4;
+ int cols = 3;
+ int[] expected = {1, 2, 3, 6, 9, 12, 11, 10, 7, 4, 5, 8};
+ assertArrayEquals(expected, ex.spiralTraversal(nums, rows, cols));
+ }
+
+ @Test
+ void testTraverse2() {
+ int[][] nums = {
+ {1, 2, 3, 4},
+ {5, 6, 7, 8}
+ };
+ int rows = 2;
+ int cols = 4;
+ int[] expected = {1, 2, 3, 4, 8, 7, 6, 5};
+ assertArrayEquals(expected, ex.spiralTraversal(nums, rows, cols));
+ }
+
+ @Test
+ void testTraverse3() {
+ int[][] nums = {
+ {1, 2, 3, 4, 5, 6},
+ {7, 8, 9, 10, 11, 12},
+ {13, 14, 15, 16, 17, 18},
+ {19, 20, 21, 22, 23, 24},
+ {25, 26, 27, 28, 29, 30}
+ };
+ int rows = 5;
+ int cols = 6;
+ int[] expected = {1, 2, 3, 4, 5, 6, 12, 18, 24, 30, 29, 28, 27, 26, 25, 19, 13, 7, 8, 9, 10, 11, 17, 23, 22, 21,
+ 20, 14, 15, 16};
+ assertArrayEquals(expected, ex.spiralTraversal(nums, rows, cols));
+ }
+}
diff --git a/src/test/java/TestTriangle.java b/src/test/java/TestTriangle.java
new file mode 100644
index 0000000..2254538
--- /dev/null
+++ b/src/test/java/TestTriangle.java
@@ -0,0 +1,54 @@
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+
+public class TestTriangle {
+ static Exercises ex;
+
+ @BeforeAll
+ static void setUp() {
+ ex = new Exercises();
+ }
+
+ @Test
+ void testTriangle0() {
+ char[][] expected = {
+ {'*'},
+ {'*', '*'}
+ };
+ assertArrayEquals(expected, ex.generateTriangle(2));
+ }
+
+ @Test
+ void testTriangle1() {
+ char[][] expected = {
+ {'*'},
+ {'*', '*'},
+ {'*', ' ', '*'},
+ {'*', '*', '*', '*'}
+ };
+ assertArrayEquals(expected, ex.generateTriangle(4));
+ }
+
+ @Test
+ void testTriangle2() {
+ char[][] expected = {
+ {'*'},
+ {'*', '*'},
+ {'*', ' ', '*'},
+ {'*', ' ', ' ', '*'},
+ {'*', ' ', ' ', ' ', '*'},
+ {'*', ' ', ' ', ' ', ' ', '*'},
+ {'*', ' ', ' ', ' ', ' ', ' ', '*'},
+ {'*', '*', '*', '*', '*', '*', '*', '*'}
+ };
+ assertArrayEquals(expected, ex.generateTriangle(8));
+ }
+
+ @Test
+ void testTriangle3() {
+ char[][] expected = {};
+ assertArrayEquals(expected, ex.generateTriangle(0));
+ }
+}