comparison run/mini/aaequality.d @ 1628:c6ef09dfba4d

add mini test set from ldc project
author Moritz Warning <moritzwarning@web.de>
date Mon, 10 Jan 2011 19:47:18 +0100
parents
children
comparison
equal deleted inserted replaced
1627:e1b954780837 1628:c6ef09dfba4d
1 void test(K,V)(K k1, V v1, K k2, V v2, K k3, V v3)
2 {
3 V[K] a, b;
4 a[k1] = v1;
5 a[k2] = v2;
6 assert(a != b);
7 assert(b != a);
8 assert(a == a);
9 assert(b == b);
10
11 b[k1] = v1;
12 assert(a != b);
13 assert(b != a);
14
15 b[k2] = v2;
16 assert(a == b);
17 assert(b == a);
18
19 b[k1] = v2;
20 assert(a != b);
21 assert(b != a);
22
23 b[k1] = v1;
24 b[k2] = v3;
25 assert(a != b);
26 assert(b != a);
27
28 b[k2] = v2;
29 b[k3] = v3;
30 assert(a != b);
31 assert(b != a);
32 }
33
34 void main()
35 {
36 test!(int,int)(1, 2, 3, 4, 5, 6);
37 test!(char[],int)("abc", 2, "def", 4, "geh", 6);
38 test!(int,char[])(1, "abc", 2, "def", 3, "geh");
39 test!(char[],char[])("123", "abc", "456", "def", "789", "geh");
40
41 Object a = new Object, b = new Object, c = new Object;
42 test!(Object, Object)(a, a, b, b, c, c);
43
44 int[int] a2 = [1:2, 2:3, 3:4];
45 int[int] b2 = [1:2, 2:5, 3:4];
46 int[int] c2 = [1:2, 2:3];
47 test!(int,int[int])(1,a2, 2,b2, 3,c2);
48 }