Update PascalTriangleTest (#2900)
* Update in indentation to makes code more readable Co-authored-by: Yang Libin <szuyanglb@outlook.com>
This commit is contained in:
parent
5c7c6c4702
commit
2a27d09a17
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package com.thealgorithms.maths;
|
package com.thealgorithms.maths;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -7,36 +6,44 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
|
|
||||||
class PascalTriangleTest {
|
class PascalTriangleTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testForOne()
|
void testForOne() {
|
||||||
{
|
int[][] result = PascalTriangle.pascal(1);
|
||||||
int[][] result = PascalTriangle.pascal(1);
|
|
||||||
int[][] expected = {{1}};
|
int[][] expected = {{1}};
|
||||||
assertArrayEquals(result,expected);
|
assertArrayEquals(result, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testForTwo()
|
void testForTwo() {
|
||||||
{
|
int[][] result = PascalTriangle.pascal(2);
|
||||||
int[][] result = PascalTriangle.pascal(2);
|
int[][] expected = {{1, 0}, {1, 1}};
|
||||||
int[][] expected = {{1,0},{1,1}};
|
assertArrayEquals(result, expected);
|
||||||
assertArrayEquals(result,expected);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testForFive()
|
|
||||||
{
|
|
||||||
int[][] result = PascalTriangle.pascal(5);
|
|
||||||
int[][] expected = {{1,0,0,0,0},{1,1,0,0,0},{1,2,1,0,0},{1,3,3,1,0},{1,4,6,4,1}};
|
|
||||||
assertArrayEquals(result,expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testForEight() {
|
|
||||||
int[][] result = PascalTriangle.pascal(8);
|
|
||||||
int[][] expected = {{1,0,0,0,0,0,0,0},{1,1,0,0,0,0,0,0},{1,2,1,0,0,0,0,0},{1,3,3,1,0,0,0,0},{1,4,6,4,1,0,0,0},{1,5,10,10,5,1,0,0},{1,6,15,20,15,6,1,0},{1,7,21,35,35,21,7,1}};
|
|
||||||
assertArrayEquals(expected, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testForFive() {
|
||||||
|
int[][] result = PascalTriangle.pascal(5);
|
||||||
|
int[][] expected = {{1, 0, 0, 0, 0},
|
||||||
|
{1, 1, 0, 0, 0},
|
||||||
|
{1, 2, 1, 0, 0},
|
||||||
|
{1, 3, 3, 1, 0},
|
||||||
|
{1, 4, 6, 4, 1}
|
||||||
|
};
|
||||||
|
assertArrayEquals(result, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testForEight() {
|
||||||
|
int[][] result = PascalTriangle.pascal(8);
|
||||||
|
int[][] expected = {{1, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
{1, 1, 0, 0, 0, 0, 0, 0},
|
||||||
|
{1, 2, 1, 0, 0, 0, 0, 0},
|
||||||
|
{1, 3, 3, 1, 0, 0, 0, 0},
|
||||||
|
{1, 4, 6, 4, 1, 0, 0, 0},
|
||||||
|
{1, 5, 10, 10, 5, 1, 0, 0},
|
||||||
|
{1, 6, 15, 20, 15, 6, 1, 0},
|
||||||
|
{1, 7, 21, 35, 35, 21, 7, 1}
|
||||||
|
};
|
||||||
|
assertArrayEquals(expected, result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user