From 06d689842adc5b4a23a049fec0f589ad9327eb75 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Tue, 6 Jul 2021 19:46:54 +0200
Subject: [PATCH] added extra comparison operators for `VarlenEntry`

---
 README.md            | 1 +
 tempsdb/varlen.pyx   | 8 +++++++-
 tests/test_varlen.py | 5 +++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 21777da..c8d0ff3 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 6ca068a..c1797f0 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 e0b98ad..2f31e45 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'))
-- 
GitLab