chiark / gitweb /
@@@ all the mess ever
[mLib] / hash / t / unihash-testgen.py
index 1fde21f947ada40c99840dd0bf2d7fc8518f78ee..a8365aef297f0e72827ef569a6b13614c03b8b88 100644 (file)
@@ -20,17 +20,22 @@ def gfmul(x, y):
 def hashtest(k, m):
   h = k
   for ch in m: h = gfmul(h ^ ord(ch), k)
-  print('  0x%08x "%s" 0x%08x;' % (k, m, h))
+  print('')
+  print('k = 0x%08x' % k)
+  print('m = "%s"' % m)
+  print('h = 0x%08x' % h)
 
 print('''\
-### Test vectors for universal hashing
-###   [generated]
+;;; -*-conf-*- Test vectors for universal hashing
+;;;   [generated]
 
-hash {''')
+[unihash]''')
 
 for k, m in [(0x00000000, 'anything you like'),
              (0x12345678, 'an exaple test string'),
              (0xb8a171f0, 'The quick brown fox jumps over the lazy dog.'),
+             (0xcc825ed5, 'Jackdaws love my big sphinx of quartz.'),
+             (0x16e98e46, 'Waltz, bad nymph, for quick jigs vex!'),
              (0x2940521b, 'A man, a plan, a canal: Panama!')]:
   hashtest(k, m)
 
@@ -38,5 +43,3 @@ k, m = 0x94b22a73, 0xbb7b1fef
 for i in xrange(48):
   hashtest(k, "If we don't succeed, we run the risk of failure.")
   k = gfmul(k, m)
-
-print('}')