Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r92617:4a184c225a22
Date: 2017-10-06 02:43 +0200
http://bitbucket.org/pypy/pypy/changeset/4a184c225a22/

Log:    Add direct tests for latin1 siphash computation

diff --git a/rpython/rlib/test/test_rsiphash.py 
b/rpython/rlib/test/test_rsiphash.py
--- a/rpython/rlib/test/test_rsiphash.py
+++ b/rpython/rlib/test/test_rsiphash.py
@@ -1,8 +1,10 @@
 import os
 from rpython.rlib.rsiphash import siphash24, _siphash24, choosen_seed
 from rpython.rlib.rsiphash import initialize_from_env, enable_siphash24
+from rpython.rlib.rsiphash import ll_hash_string_siphash24
 from rpython.rlib.objectmodel import compute_hash
 from rpython.rlib.rarithmetic import intmask
+from rpython.rtyper.annlowlevel import llstr, llunicode
 from rpython.rtyper.lltypesystem import llmemory, rffi
 from rpython.translator.c.test.test_genc import compile
 
@@ -38,14 +40,26 @@
                       test_misaligned_path=True):
         x = siphash24(s)
         y = _siphash24(llmemory.cast_ptr_to_adr(rffi.ptradd(q, 1)), len(s))
+        z = ll_hash_string_siphash24(llstr(s))
     rffi.free_charp(q)
     assert x == y
+    assert z == intmask(x)
     return x
 
 def test_siphash24():
     for expected, string in CASES:
         assert check(string) == expected
 
+def check_latin1(s, expected):
+    with choosen_seed(0x8a9f065a358479f4, 0x11cb1e9ee7f40e1f,
+                      test_misaligned_path=True):
+        z = ll_hash_string_siphash24(llunicode(s))
+    assert z == intmask(expected)
+
+def test_siphash24_latin1_unicode():
+    for expected, string in CASES:
+        check_latin1(string.decode('latin1'), expected)
+
 def test_fix_seed():
     old_val = os.environ.get('PYTHONHASHSEED', None)
     try:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to