Skip to content

Commit 2a27d09

Browse files
Update PascalTriangleTest (TheAlgorithms#2900)
* Update in indentation to makes code more readable Co-authored-by: Yang Libin <szuyanglb@outlook.com>
1 parent 5c7c6c4 commit 2a27d09

File tree

1 file changed

+39
-32
lines changed

1 file changed

+39
-32
lines changed
Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
package com.thealgorithms.maths;
32

43
import org.junit.jupiter.api.Test;
@@ -7,36 +6,44 @@
76

87
class PascalTriangleTest {
98

10-
@Test
11-
void testForOne()
12-
{
13-
int[][] result = PascalTriangle.pascal(1);
9+
@Test
10+
void testForOne() {
11+
int[][] result = PascalTriangle.pascal(1);
1412
int[][] expected = {{1}};
15-
assertArrayEquals(result,expected);
16-
}
17-
18-
@Test
19-
void testForTwo()
20-
{
21-
int[][] result = PascalTriangle.pascal(2);
22-
int[][] expected = {{1,0},{1,1}};
23-
assertArrayEquals(result,expected);
24-
}
25-
26-
@Test
27-
void testForFive()
28-
{
29-
int[][] result = PascalTriangle.pascal(5);
30-
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}};
31-
assertArrayEquals(result,expected);
32-
}
33-
34-
@Test
35-
void testForEight() {
36-
int[][] result = PascalTriangle.pascal(8);
37-
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}};
38-
assertArrayEquals(expected, result);
39-
}
40-
41-
13+
assertArrayEquals(result, expected);
14+
}
15+
16+
@Test
17+
void testForTwo() {
18+
int[][] result = PascalTriangle.pascal(2);
19+
int[][] expected = {{1, 0}, {1, 1}};
20+
assertArrayEquals(result, expected);
21+
}
22+
23+
@Test
24+
void testForFive() {
25+
int[][] result = PascalTriangle.pascal(5);
26+
int[][] expected = {{1, 0, 0, 0, 0},
27+
{1, 1, 0, 0, 0},
28+
{1, 2, 1, 0, 0},
29+
{1, 3, 3, 1, 0},
30+
{1, 4, 6, 4, 1}
31+
};
32+
assertArrayEquals(result, expected);
33+
}
34+
35+
@Test
36+
void testForEight() {
37+
int[][] result = PascalTriangle.pascal(8);
38+
int[][] expected = {{1, 0, 0, 0, 0, 0, 0, 0},
39+
{1, 1, 0, 0, 0, 0, 0, 0},
40+
{1, 2, 1, 0, 0, 0, 0, 0},
41+
{1, 3, 3, 1, 0, 0, 0, 0},
42+
{1, 4, 6, 4, 1, 0, 0, 0},
43+
{1, 5, 10, 10, 5, 1, 0, 0},
44+
{1, 6, 15, 20, 15, 6, 1, 0},
45+
{1, 7, 21, 35, 35, 21, 7, 1}
46+
};
47+
assertArrayEquals(expected, result);
48+
}
4249
}

0 commit comments

Comments
 (0)