thashes.nim 821 B

1234567891011121314151617181920212223242526272829303132333435
  1. discard """
  2. output: '''
  3. [Suite] hashes
  4. [Suite] hashing
  5. '''
  6. """
  7. import unittest, hashes
  8. suite "hashes":
  9. suite "hashing":
  10. test "0.0 and -0.0 should have the same hash value":
  11. var dummy = 0.0
  12. check hash(dummy) == hash(-dummy)
  13. test "VM and runtime should make the same hash value (hashIdentity)":
  14. const hi123 = hashIdentity(123)
  15. check hashIdentity(123) == hi123
  16. test "VM and runtime should make the same hash value (hashWangYi1)":
  17. const wy123 = hashWangYi1(123)
  18. check hashWangYi1(123) == wy123
  19. test "hashIdentity value incorrect at 456":
  20. check hashIdentity(456) == 456
  21. test "hashWangYi1 value incorrect at 456":
  22. when Hash.sizeof < 8:
  23. check hashWangYi1(456) == 1293320666
  24. else:
  25. check hashWangYi1(456) == -6421749900419628582