mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 23:15:17 +08:00
* Enhance UnquiePaths DP problem solution * Update testcases * Linter issue resolved * Code review comments * Code review comments * Code review comments * Code review comments --------- Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This commit is contained in:
@ -0,0 +1,58 @@
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class UniquePathsTests {
|
||||
|
||||
@Test
|
||||
public void testUniquePaths_3x3() {
|
||||
assertEquals(6, UniquePaths.uniquePaths(3, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUniquePaths_1x1() {
|
||||
assertEquals(1, UniquePaths.uniquePaths(1, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUniquePaths_3x7() {
|
||||
assertEquals(28, UniquePaths.uniquePaths(3, 7));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUniquePaths_7x3() {
|
||||
assertEquals(28, UniquePaths.uniquePaths(7, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUniquePaths_100x100() {
|
||||
assertThrows(ArithmeticException.class, () -> UniquePaths.uniquePaths(100, 100));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUniquePaths2_3x3() {
|
||||
assertEquals(6, UniquePaths.uniquePaths2(3, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUniquePaths2_1x1() {
|
||||
assertEquals(1, UniquePaths.uniquePaths2(1, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUniquePaths2_3x7() {
|
||||
assertEquals(28, UniquePaths.uniquePaths2(3, 7));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUniquePaths2_7x3() {
|
||||
assertEquals(28, UniquePaths.uniquePaths2(7, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUniquePaths2_100x100() {
|
||||
assertThrows(ArithmeticException.class, () -> UniquePaths.uniquePaths2(100, 100));
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.thealgorithms.others;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import com.thealgorithms.dynamicprogramming.UniquePaths;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class UniquePathsTests {
|
||||
|
||||
@Test
|
||||
void testForOneElement() {
|
||||
assertTrue(UniquePaths.uniquePaths(3, 7, 28));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForTwoElements() {
|
||||
assertTrue(UniquePaths.uniquePaths(3, 2, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForThreeElements() {
|
||||
assertTrue(UniquePaths.uniquePaths(3, 3, 6));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFourElements() {
|
||||
assertTrue(UniquePaths.uniquePaths(4, 6, 56));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForFiveElements() {
|
||||
assertTrue(UniquePaths.uniquePaths2(3, 5, 15));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSixElements() {
|
||||
assertTrue(UniquePaths.uniquePaths2(6, 2, 6));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForSevenElements() {
|
||||
assertTrue(UniquePaths.uniquePaths2(5, 9, 495));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForEightElements() {
|
||||
assertTrue(UniquePaths.uniquePaths2(4, 8, 120));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user