summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-08-30 15:42:27 (GMT)
committerGitHub <noreply@github.com>2024-08-30 15:42:27 (GMT)
commitd8e69b2c1b3388c31a6083cfdd9dc9afff5b9860 (patch)
treeeb78955c066631fdd52b00ddfd26d4fb676f9e36 /Lib
parent3d60dfbe1755e00ab20d0ee81281886be77ad5da (diff)
downloadcpython-d8e69b2c1b3388c31a6083cfdd9dc9afff5b9860.zip
cpython-d8e69b2c1b3388c31a6083cfdd9dc9afff5b9860.tar.gz
cpython-d8e69b2c1b3388c31a6083cfdd9dc9afff5b9860.tar.bz2
gh-122854: Add Py_HashBuffer() function (#122855)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_capi/test_hash.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_capi/test_hash.py b/Lib/test/test_capi/test_hash.py
index cb2b363..f553ffb 100644
--- a/Lib/test/test_capi/test_hash.py
+++ b/Lib/test/test_capi/test_hash.py
@@ -78,6 +78,16 @@ class CAPITest(unittest.TestCase):
VOID_P_MAX = -1 & (2 ** (8 * SIZEOF_VOID_P) - 1)
self.assertEqual(hash_pointer(VOID_P_MAX), -2)
+ def test_hash_buffer(self):
+ hash_buffer = _testcapi.hash_buffer
+
+ def check(data):
+ self.assertEqual(hash_buffer(data), hash(data))
+
+ check(b'')
+ check(b'abc')
+ check(b'x' * 1024)
+
if __name__ == "__main__":
unittest.main()