File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/test/java/com/thealgorithms/strings Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .thealgorithms .strings ;
2
2
3
+ import org .junit .jupiter .api .Test ;
3
4
import org .junit .jupiter .params .ParameterizedTest ;
4
5
import org .junit .jupiter .params .provider .MethodSource ;
5
6
@@ -29,4 +30,17 @@ private static Stream<Object[]> provideTestData() {
29
30
void arrangeTest (String input1 , String input2 , String expected ) {
30
31
assertEquals (expected , AlternativeStringArrange .arrange (input1 , input2 ));
31
32
}
33
+
34
+ // Testing private constructor to prevent instantiation
35
+ @ Test
36
+ void preventInstantiationTest () {
37
+ try {
38
+ var constructor = AlternativeStringArrange .class .getDeclaredConstructor ();
39
+ constructor .setAccessible (true );
40
+ constructor .newInstance ();
41
+ } catch (Exception e ) {
42
+ assertEquals (IllegalStateException .class , e .getCause ().getClass ());
43
+ assertEquals ("Utility class" , e .getCause ().getMessage ());
44
+ }
45
+ }
32
46
}
You can’t perform that action at this time.
0 commit comments