Skip to content

Commit 8a18e1a

Browse files
resolved errors
1 parent 07276fc commit 8a18e1a

File tree

7 files changed

+37
-25
lines changed

7 files changed

+37
-25
lines changed

src/main/java/com/thealgorithms/searches/BinarySearch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ private <T extends Comparable<T>> int search(T[] array, T key, int left, int rig
6262
return search(array, key, median + 1, right);
6363
}
6464
}
65-
}
65+
}
66+

src/main/java/com/thealgorithms/shufflealogrithm/WeightedShuffle.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ public static void main(String[] args) {
5252
System.out.print(num + " ");
5353
}
5454
}
55-
}
55+
}
56+
57+
// Add a newline character here (just press Enter)

src/test/java/com/thealgorithms/datastructures/trees/BinaryTreeTest.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.thealgorithms.datastructures.trees;
22

3-
import static org.junit.jupiter.api.Assertions.*;
4-
53
import org.junit.jupiter.api.Test;
4+
import org.junit.jupiter.api.Assertions;
65

76
public class BinaryTreeTest {
87

@@ -16,11 +15,11 @@ void test1() {
1615
t.put(9);
1716
t.put(12);
1817

19-
assertNotNull(t.find(5), "Node with value 5 should exist in the tree.");
20-
assertEquals(5, t.find(5).data);
18+
Assertions.assertNotNull(t.find(5), "Node with value 5 should exist in the tree.");
19+
Assertions.assertEquals(5, t.find(5).data);
2120

22-
assertNotNull(t.find(7), "Node with value 7 should exist in the tree.");
23-
assertEquals(7, t.find(7).data);
21+
Assertions.assertNotNull(t.find(7), "Node with value 7 should exist in the tree.");
22+
Assertions.assertEquals(7, t.find(7).data);
2423
}
2524

2625
// Test for removing data and checking the new root
@@ -38,8 +37,8 @@ void test2() {
3837
t.remove(5);
3938
t.remove(7);
4039

41-
assertNotNull(t.getRoot(), "Root should not be null after removals.");
42-
assertEquals(9, t.getRoot().data);
40+
Assertions.assertNotNull(t.getRoot(), "Root should not be null after removals.");
41+
Assertions.assertEquals(9, t.getRoot().data);
4342
}
4443

4544
// Test for attempting to remove a nonexistent node
@@ -52,8 +51,8 @@ void test3() {
5251
t.put(9);
5352
t.put(12);
5453

55-
assertTrue(t.remove(9), "Node with value 9 should be removed.");
56-
assertFalse(t.remove(398745987),
54+
Assertions.assertTrue(t.remove(9), "Node with value 9 should be removed.");
55+
Assertions.assertFalse(t.remove(398745987),
5756
"Removing a nonexistent node should return false.");
5857
}
5958

@@ -68,7 +67,7 @@ void test4() {
6867
t.put(12);
6968

7069
// Ensure root is not null before traversal
71-
assertNotNull(t.getRoot(), "Root should not be null for traversal.");
70+
Assertions.assertNotNull(t.getRoot(), "Root should not be null for traversal.");
7271

7372
// Invoke traversal methods to increase test coverage
7473
t.bfs(t.getRoot());
@@ -77,8 +76,8 @@ void test4() {
7776
t.postOrder(t.getRoot());
7877

7978
// Additional assertions
80-
assertTrue(t.remove(9), "Node with value 9 should be removed.");
81-
assertFalse(t.remove(398745987),
79+
Assertions.assertTrue(t.remove(9), "Node with value 9 should be removed.");
80+
Assertions.assertFalse(t.remove(398745987),
8281
"Removing a nonexistent node should return false.");
8382
}
84-
}
83+
}

src/test/java/com/thealgorithms/searches/BinarySearchTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,5 @@ void testBinarySearchLargeArray() {
105105
int expectedIndex = 9999; // Index of the last element
106106
Assertions.assertEquals(expectedIndex, binarySearch.find(array, key), "The index of the last element should be 9999.");
107107
}
108-
}
108+
}
109+

src/test/java/com/thealgorithms/shufflealgorithm/GroupShuffleTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ void testGroupShuffleGroupSizeOne() {
9191
System.out.println("Shuffled Groups (Group Size One Test): "
9292
+ shuffledGroups);
9393
}
94-
}
94+
}
95+

src/test/java/com/thealgorithms/shufflealgorithm/ShuffleByRangeTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,5 @@ void testShuffleByRangeLargeArray() {
8585
"Elements at index " + i + " should be unchanged");
8686
}
8787
}
88-
}
88+
}
89+

src/test/java/com/thealgorithms/shufflealgorithm/WeightedShuffleTest.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ void testWeightedShuffleSameWeights() {
4949
// The order should remain the same or be any permutation since weights are
5050
// equal
5151
boolean firstElementMatches =
52-
array[0] == 1 ||
53-
array[0] == 2 ||
54-
array[0] == 3 ||
52+
array[0] == 1
53+
||
54+
array[0] == 2
55+
||
56+
array[0] == 3
57+
||
5558
array[0] == 4;
5659
Assertions.assertTrue(firstElementMatches);
5760
}
@@ -95,9 +98,13 @@ void testWeightedShuffleZeroWeights() {
9598
// The order should remain the same or be any permutation since all weights
9699
// are equal
97100
boolean firstElementMatches =
98-
array[0] == 5 ||
99-
array[0] == 10 ||
101+
array[0] == 5
102+
||
103+
array[0] == 10
104+
||
100105
array[0] == 15;
101106
Assertions.assertTrue(firstElementMatches);
102107
}
103-
}
108+
}
109+
110+
// Add a newline character here (just press Enter)

0 commit comments

Comments
 (0)