Skip to content

Commit b9111e9

Browse files
committed
03-04 throw exception added.
1 parent 58865b0 commit b9111e9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

03-Sorting-Advance/Course Code (Java)/04-Merge-Sort-Bottom-Up/src/bobo/algo/SortTestHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.lang.reflect.Method;
44
import java.lang.Class;
5+
import java.security.InvalidAlgorithmParameterException;
56
import java.util.Random;
67

78
public class SortTestHelper {
@@ -82,6 +83,8 @@ public static void testSort(String sortClassName, Comparable[] arr){
8283
long endTime = System.currentTimeMillis();
8384

8485
assert isSorted( arr );
86+
if(!isSorted(arr))
87+
throw new InvalidAlgorithmParameterException("sort failed!");
8588

8689
System.out.println( sortClass.getSimpleName()+ " : " + (endTime-startTime) + "ms" );
8790
}

0 commit comments

Comments
 (0)