PageRenderTime 10ms CodeModel.GetById 7ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/specs/hashes/digest.ds

http://github.com/wilkie/djehuty
Unknown | 57 lines | 43 code | 14 blank | 0 comment | 0 complexity | e5ec3640561da359d6f784c0ed90ed38 MD5 | raw file
 1module specs.hashes.digest;
 2
 3import testing.support;
 4
 5import hashes.digest;
 6
 7describe digest() {
 8	describe creation() {
 9		it should_allow_for_64_bits() {
10			Digest d = new Digest(0xDEADBEEF, 0x01234567);
11			string s = d.toString();
12
13			should(s == "deadbeef01234567");
14		}
15
16		it should_allow_for_128_bits() {
17			Digest d = new Digest(0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567);
18			string s = d.toString();
19
20			should(s == "deadbeef01234567deadbeef01234567");
21		}
22
23		it should_allow_for_160_bits() {
24			Digest d = new Digest(0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567, 0xDEADBEEF);
25			string s = d.toString();
26
27			should(s == "deadbeef01234567deadbeef01234567deadbeef");
28		}
29
30		it should_allow_for_192_bits() {
31			Digest d = new Digest(0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567);
32			string s = d.toString();
33
34			should(s == "deadbeef01234567deadbeef01234567deadbeef01234567");
35		}
36	}
37
38	describe comparison() {
39		it should_work_for_equals_overload() {
40			Digest d1 = new Digest(0xDEADBEEF);
41			Digest d2 = new Digest(0x01234567);
42			Digest d3 = new Digest(0xDEADBEEF);
43
44			should(d1 == d3);
45			shouldNot(d1 == d2);
46		}
47
48		it should_work_for_equals_function() {
49			Digest d1 = new Digest(0xDEADBEEF);
50			Digest d2 = new Digest(0x01234567);
51			Digest d3 = new Digest(0xDEADBEEF);
52
53			should(d1.equals(d3));
54			shouldNot(d1.equals(d2));
55		}
56	}
57}