diff --git a/README.md b/README.md index 21777da30270d93cafda58a895592cf0d35b589e..c8d0ff3ef7933cc29ed7aa49daaa18aa58bbb274 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Consult the docs for how to disable it. ## v0.6.4 * fixed a bug with slicing chunks +* added extra comparison operators for `VarlenEntry` ## v0.6.3 diff --git a/tempsdb/varlen.pyx b/tempsdb/varlen.pyx index 6ca068a8d769e926116f668b8bef44399b4fae7c..c1797f024fbf113baf4322ef5579f5f62958243d 100644 --- a/tempsdb/varlen.pyx +++ b/tempsdb/varlen.pyx @@ -91,9 +91,15 @@ cdef class VarlenEntry: def __gt__(self, other) -> bool: return self.to_bytes() > other - def __le__(self, other) -> bool: + def __ge__(self, other) -> bool: + return self.to_bytes() >= other + + def __lt__(self, other) -> bool: return self.to_bytes() < other + def __le__(self, other) -> bool: + return self.to_bytes() <= other + def __eq__(self, other) -> bool: return self.to_bytes() == other diff --git a/tests/test_varlen.py b/tests/test_varlen.py index e0b98ad4d0b8e76c03d4b0f8f78a495e9fa86e12..2f31e45e722241773e45e70907d9aa66a91a0c64 100644 --- a/tests/test_varlen.py +++ b/tests/test_varlen.py @@ -34,6 +34,11 @@ class TestVarlen(unittest.TestCase): with varlen.iterate_range(0, 20) as iterator: ve = iterator.get_next() while ve is not None: + self.assertGreater(ve, b'tes') + self.assertLess(ve, b'tez') + self.assertGreaterEqual(ve, b'tes') + self.assertLessEqual(ve, b'tez') + hash(ve) self.assertTrue(ve.slice(0, 4), b'test') self.assertTrue(ve.startswith(b'test ')) # self.assertTrue(ve.endswith(b'skarabeusza'))