1 module tests.pass.normal;
2 
3 import unit_threaded.all;
4 
5 
6 class IntEqualTest: TestCase {
7     override void test() {
8         checkNotEqual(1, 5);
9         checkNotEqual(5, 1);
10         checkEqual(3, 3);
11         checkEqual(2, 2);
12     }
13 }
14 
15 class DoubleEqualTest: TestCase {
16     override void test() {
17         checkNotEqual(1.0, 2.0);
18         checkEqual(2.0, 2.0);
19         checkEqual(2.0, 2.0);
20     }
21 }
22 
23 void testEqual() {
24     checkEqual(1, 1);
25     checkEqual(1.0, 1.0);
26     checkEqual("foo", "foo");
27 }
28 
29 void testNotEqual() {
30     checkNotEqual(3, 4);
31     checkNotEqual(5.0, 6.0);
32     checkNotEqual("foo", "bar");
33 }
34 
35 
36 private class MyException: Exception {
37     this() {
38         super("MyException");
39     }
40 }
41 
42 void testThrown() {
43     checkThrown!MyException(throwFunc());
44 }
45 
46 void testNotThrown() {
47     checkNotThrown(nothrowFunc());
48 }
49 
50 private void throwFunc() {
51     throw new MyException;
52 }
53 
54 private void nothrowFunc() nothrow {
55     {}
56 }
57 
58 unittest {
59     assert(true); //unit test block that always passes
60 }
61 
62 private class MyClass {
63     int i;
64     double d;
65     this(int i, double d) {
66         this.i = i;
67         this.d = d;
68     }
69     override string toString() const {
70         import std.conv;
71         return text("MyClass(", i, ", ", d, ")");
72     }
73 }
74 
75 void testEqualClass() {
76     const foo = new MyClass(2, 3.0);
77     const bar = new MyClass(2, 3.0);
78     const baz = new MyClass(3, 3.0);
79 
80     checkEqual(foo, bar);
81     checkEqual(bar, foo);
82     checkNotEqual(foo, baz);
83     checkNotEqual(bar, baz);
84     checkNotEqual(baz, foo);
85     checkNotEqual(baz, bar);
86 }