History

Implemented some tests

Dmitry Kabak (userdima committed 13 years ago

Commit 3968fd71 parent e14eff611 files · +289 −0Browse files

Showing the changes to java/tests/utils (2 of 11 files). Show all

Unified · Split

2 files
  1. java/tests/utils/Utils.java +61 −0
  2. java/tests/utils/mkfile +19 −0
java/tests/utils/Utils.java+61−0
@@ -0,0 +1,61 @@
1+
2+package utils;
3+
4+public class Utils {
5+
6+ public static class AssertionFailedException extends java.lang.RuntimeException {
7+ public AssertionFailedException(String msg) {
8+ super(msg);
9+ System.err.println("Asserion failed: " + msg);
10+ }
11+ }
12+
13+ private Utils() {
14+ }
15+
16+ public static void assertEquals(int expected, int found) throws AssertionFailedException {
17+ assertEquals(expected, found, "expected " + expected + " but found " + found);
18+ }
19+ public static void assertEquals(int expected, int found, String msg) throws AssertionFailedException {
20+ if (expected != found)
21+ throw new AssertionFailedException(msg);
22+ }
23+
24+
25+ public static void assertEquals(long expected, long found) throws AssertionFailedException {
26+ assertEquals(expected, found, "expected " + expected + " but found " + found);
27+ }
28+ public static void assertEquals(long expected, long found, String msg) throws AssertionFailedException {
29+ if (expected != found)
30+ throw new AssertionFailedException(msg);
31+ }
32+
33+ public static void assertEquals(float expected, float found) throws AssertionFailedException {
34+ assertEquals(expected, found, "expected " + expected + " but found " + found);
35+ }
36+ public static void assertEquals(float expected, float found, String msg) throws AssertionFailedException {
37+ if (expected != found)
38+ throw new AssertionFailedException(msg);
39+ }
40+
41+ public static void assertEquals(double expected, double found) throws AssertionFailedException {
42+ assertEquals(expected, found, "expected " + expected + " but found " + found);
43+ }
44+ public static void assertEquals(double expected, double found, String msg) throws AssertionFailedException {
45+ if (expected != found)
46+ throw new AssertionFailedException(msg);
47+ }
48+
49+ public static void assertEquals(Object expected, Object found) throws AssertionFailedException {
50+ assertEquals(expected, found, "expected " + expected + " but found " + found);
51+ }
52+ public static void assertEquals(Object expected, Object found, String msg) throws AssertionFailedException {
53+ if (!expected.equals(found))
54+ throw new AssertionFailedException(msg);
55+ }
56+
57+ public static void main(String[] args) {
58+ // This is only for convenience, so that
59+ // test system may assume this is also a test
60+ }
61+}
java/tests/utils/mkfile+19−0
@@ -0,0 +1,19 @@
1+<../../../mkconfig
2+ROOT=/Users/zubr/dev/distributed/inferno-java
3+
4+UTILS= Utils\
5+
6+OBJ=${UTILS:%=%.dis}
7+JAVAC=os -d $ROOT`{pwd} javac
8+
9+all:QV: $OBJ
10+ echo Compiled test utils
11+
12+%.dis:QE: %.class
13+ for c in $stem*.class {java/j2d -g $c}
14+
15+%.class:Q: %.java
16+ $JAVAC $stem.java
17+
18+clean:QV:
19+ rm *.dis *.class *.sbl