11package com .devstromo .day1110 ;
22
3+ import org .junit .jupiter .api .DisplayName ;
34import org .junit .jupiter .api .Test ;
45
56import static org .junit .jupiter .api .Assertions .*;
@@ -8,54 +9,37 @@ class ProblemUnitTest {
89 private final Problem problem = new Problem ();
910
1011 @ Test
11- void testSimpleTriplet () {
12- assertTrue (problem .solve (new int []{3 , 4 , 5 }));
13- }
14-
15- @ Test
16- void testMultipleTriplets () {
17- assertTrue (problem .solve (new int []{10 , 4 , 6 , 8 , 5 }));
18- }
19-
20- @ Test
21- void testNoTriplet () {
12+ @ DisplayName ("Test Pythagorean triplet" )
13+ void testPythagoreanTriplet () {
14+ assertFalse (problem .solve (new int []{0 , 0 , 0 }));
2215 assertFalse (problem .solve (new int []{1 , 2 , 3 }));
23- }
24-
25- @ Test
26- void testEmptyArray () {
27- assertFalse (problem .solve (new int []{}));
28- }
29-
30- @ Test
31- void testSingleElement () {
32- assertFalse (problem .solve (new int []{5 }));
33- }
34-
35- @ Test
36- void testOnlyTwoElements () {
3716 assertFalse (problem .solve (new int []{5 , 12 }));
38- }
39-
40- @ Test
41- void testWithDuplicates () {
42- assertTrue (problem .solve (new int []{5 , 5 , 3 , 4 }));
43- }
44-
45- @ Test
46- void testWithZeros () {
47- assertFalse (problem .solve (new int []{0 , 0 , 0 }));
48- }
49-
50- @ Test
51- void testNegativeNumbers () {
17+ assertFalse (problem .solve (new int []{5 }));
18+ assertFalse (problem .solve (new int []{}));
5219 assertTrue (problem .solve (new int []{-3 , 4 , 5 }));
20+ assertTrue (problem .solve (new int []{10 , 4 , 6 , 8 , 5 }));
5321 assertTrue (problem .solve (new int []{3 , -4 , 5 }));
5422 assertTrue (problem .solve (new int []{3 , 4 , -5 }));
23+ assertTrue (problem .solve (new int []{3 , 4 , 5 }));
24+ assertTrue (problem .solve (new int []{5 , 5 , 3 , 4 }));
25+ assertTrue (problem .solve (new int []{9 , 40 , 41 }));
5526 }
5627
5728 @ Test
58- void testLargeTriplet () {
59- assertTrue (problem .solve (new int []{9 , 40 , 41 }));
29+ @ DisplayName ("Test Pythagorean triplet with two pointers" )
30+ void testPythagoreanTripletWithTwoPointers () {
31+ assertFalse (problem .solveTwoPointers (new int []{0 , 0 , 0 }));
32+ assertFalse (problem .solveTwoPointers (new int []{1 , 2 , 3 }));
33+ assertFalse (problem .solveTwoPointers (new int []{5 , 12 }));
34+ assertFalse (problem .solveTwoPointers (new int []{5 }));
35+ assertFalse (problem .solveTwoPointers (new int []{}));
36+ assertTrue (problem .solveTwoPointers (new int []{-3 , 4 , 5 }));
37+ assertTrue (problem .solveTwoPointers (new int []{10 , 4 , 6 , 8 , 5 }));
38+ assertTrue (problem .solveTwoPointers (new int []{3 , -4 , 5 }));
39+ assertTrue (problem .solveTwoPointers (new int []{3 , 4 , -5 }));
40+ assertTrue (problem .solveTwoPointers (new int []{3 , 4 , 5 }));
41+ assertTrue (problem .solveTwoPointers (new int []{5 , 5 , 3 , 4 }));
42+ assertTrue (problem .solveTwoPointers (new int []{9 , 40 , 41 }));
6043 }
44+
6145}
0 commit comments