forked from cristianadinea/OpenSourceContributions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WalaTestCase.java
66 lines (54 loc) · 1.71 KB
/
WalaTestCase.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.ibm.wala.core.tests.util;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.runner.JUnitCore;
import com.ibm.wala.util.heapTrace.HeapTracer;
import com.ibm.wala.util.warnings.Warnings;
/**
* Simple extension to JUnit test case.
*/
public abstract class WalaTestCase {
final private static boolean ANALYZE_LEAKS = false;
public static boolean useShortProfile() {
String profile = System.getProperty("com.ibm.wala.junit.profile", "long");
if (profile.equals("short")) {
return true;
} else {
return false;
}
}
/*
* @see junit.framework.TestCase#setUp()
*/
@Before
public void setUp() throws Exception {
}
/*
* @see junit.framework.TestCase#tearDown()
*/
@After
public void tearDown() throws Exception {
Warnings.clear();
if (ANALYZE_LEAKS) {
HeapTracer.analyzeLeaks();
}
}
/**
* Utility function: each DetoxTestCase subclass can have a main() method that calls this, to create a test suite consisting of
* just this test. Useful when investigating a single failing test.
*/
protected static void justThisTest(Class<?> testClass) {
JUnitCore.runClasses(testClass);
}
protected static void assertBound(String tag, double quantity, double bound) {
String msg = tag + ", quantity: " + quantity + ", bound:" + bound;
System.err.println(msg);
Assert.assertTrue(msg, quantity <= bound);
}
protected static void assertBound(String tag, int quantity, int bound) {
String msg = tag + ", quantity: " + quantity + ", bound:" + bound;
System.err.println(msg);
Assert.assertTrue(msg, quantity <= bound);
}
}