-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestTools.java
44 lines (35 loc) · 1.12 KB
/
TestTools.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package quick;
// import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Random;
public class TestTools {
static int[] generateIntArray(int size, int min, int max) {
Random rand = new Random();
int[] a = new int[size];
int range = max + 1 - min;
for (int i = 0; i < size; i++) {
a[i] = rand.nextInt(range) + min;
}
return a;
}
static int[] generateIntArray(int size, int min) {
Random rand = new Random();
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = rand.nextInt() + min;
}
return a;
}
static void testIntArraysEquals(int[] sorted, int[] arr) {
// System.out.println("Sys sort: " + Arrays.toString(sorted));
// System.out.println();
// System.out.println("My sort: " + Arrays.toString(arr));
// System.out.println();
assertTrue("Expected sorted array", Arrays.equals(arr, sorted));
}
static void assertTrue(String msg, boolean b) {
if (!b) {
throw new AssertionError(msg);
}
}
}