From b555e2dc5df7c777f38ca5c9a6f5a32760ded689 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 2 Aug 2014 21:58:31 +0100 Subject: [PATCH] * Add hash tests --- tests/test_hash_table.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/test_hash_table.py diff --git a/tests/test_hash_table.py b/tests/test_hash_table.py new file mode 100644 index 000000000..2ea7d3797 --- /dev/null +++ b/tests/test_hash_table.py @@ -0,0 +1,18 @@ +import pytest + +from spacy._hashing import FixedTable + + +def test_insert(): + table = FixedTable(20) + table[5] = 10 + assert table.bucket(5) == 5 + assert table[4] == 0 + assert table[5] == 10 + +def test_clobber(): + table = FixedTable(10) + table[9] = 1 + assert table.bucket(9) == 9 + assert table.bucket(19) == 9 +