PageRenderTime 32ms CodeModel.GetById 30ms 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
  1. module specs.hashes.digest;
  2. import testing.support;
  3. import hashes.digest;
  4. describe digest() {
  5. describe creation() {
  6. it should_allow_for_64_bits() {
  7. Digest d = new Digest(0xDEADBEEF, 0x01234567);
  8. string s = d.toString();
  9. should(s == "deadbeef01234567");
  10. }
  11. it should_allow_for_128_bits() {
  12. Digest d = new Digest(0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567);
  13. string s = d.toString();
  14. should(s == "deadbeef01234567deadbeef01234567");
  15. }
  16. it should_allow_for_160_bits() {
  17. Digest d = new Digest(0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567, 0xDEADBEEF);
  18. string s = d.toString();
  19. should(s == "deadbeef01234567deadbeef01234567deadbeef");
  20. }
  21. it should_allow_for_192_bits() {
  22. Digest d = new Digest(0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567);
  23. string s = d.toString();
  24. should(s == "deadbeef01234567deadbeef01234567deadbeef01234567");
  25. }
  26. }
  27. describe comparison() {
  28. it should_work_for_equals_overload() {
  29. Digest d1 = new Digest(0xDEADBEEF);
  30. Digest d2 = new Digest(0x01234567);
  31. Digest d3 = new Digest(0xDEADBEEF);
  32. should(d1 == d3);
  33. shouldNot(d1 == d2);
  34. }
  35. it should_work_for_equals_function() {
  36. Digest d1 = new Digest(0xDEADBEEF);
  37. Digest d2 = new Digest(0x01234567);
  38. Digest d3 = new Digest(0xDEADBEEF);
  39. should(d1.equals(d3));
  40. shouldNot(d1.equals(d2));
  41. }
  42. }
  43. }