-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestUtils.java
More file actions
40 lines (33 loc) · 1.08 KB
/
TestUtils.java
File metadata and controls
40 lines (33 loc) · 1.08 KB
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
public class TestUtils {
public static void log(String s) {
System.out.println(s);
}
public static boolean equal(int a, int b) {
return a == b;
}
public static boolean equal(Coord a, Coord b) {
return (a.x == b.x && a.y == b.y);
}
public static boolean equal(boolean a, boolean b) {
return a == b;
}
public static boolean notEqual(int a, int b) {
return a != b;
}
public static void expect(boolean condition, String errorString) {
if(!condition)
log("x " + getCallerClassName() + ": " + errorString);
else
log(".");
}
public static String getCallerClassName() {
StackTraceElement[] stElements = Thread.currentThread().getStackTrace();
for (int i=1; i<stElements.length; i++) {
StackTraceElement ste = stElements[i];
if (!ste.getClassName().equals(TestUtils.class.getName()) && ste.getClassName().indexOf("java.lang.Thread")!=0) {
return ste.getClassName();
}
}
return null;
}
}