Skip to content

Commit 0ed6d3b

Browse files
fixed checkstyle violation in NearestElementTest.java
1 parent c5c31c8 commit 0ed6d3b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/java/com/thealgorithms/stacks/NearestElementTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.thealgorithms.stacks;
22

3+
import java.lang.reflect.Constructor;
34
import java.util.Arrays;
45

56
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@@ -44,4 +45,16 @@ void testNearestSmallerToLeft() {
4445
int[] expected = {-1, 4, -1, 2, 2};
4546
assertArrayEquals(expected, result);
4647
}
48+
49+
@Test
50+
void testPrivateConstructor() throws Exception {
51+
Constructor<NearestElement> constructor
52+
= NearestElement.class.getDeclaredConstructor();
53+
constructor.setAccessible(true);
54+
try {
55+
constructor.newInstance();
56+
} catch (Exception ignored) {
57+
// Expected exception: constructor throws UnsupportedOperationException
58+
}
59+
}
4760
}

0 commit comments

Comments
 (0)