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 11package com .thealgorithms .strings ;
22
3+ import org .junit .jupiter .api .Test ;
34import org .junit .jupiter .params .ParameterizedTest ;
45import org .junit .jupiter .params .provider .MethodSource ;
56
@@ -29,4 +30,17 @@ private static Stream<Object[]> provideTestData() {
2930 void arrangeTest (String input1 , String input2 , String expected ) {
3031 assertEquals (expected , AlternativeStringArrange .arrange (input1 , input2 ));
3132 }
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+ }
3246}
You can’t perform that action at this time.
0 commit comments