summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/pychrysalide/format/symbol.c2
-rw-r--r--tests/format/symbol.py24
2 files changed, 25 insertions, 1 deletions
diff --git a/plugins/pychrysalide/format/symbol.c b/plugins/pychrysalide/format/symbol.c
index af03473..932b0fd 100644
--- a/plugins/pychrysalide/format/symbol.c
+++ b/plugins/pychrysalide/format/symbol.c
@@ -103,7 +103,7 @@ static PyObject *py_binary_symbol_richcompare(PyObject *a, PyObject *b, int op)
}
sym_a = G_BIN_SYMBOL(pygobject_get(a));
- sym_a = G_BIN_SYMBOL(pygobject_get(b));
+ sym_b = G_BIN_SYMBOL(pygobject_get(b));
status = g_binary_symbol_cmp(&sym_a, &sym_b);
diff --git a/tests/format/symbol.py b/tests/format/symbol.py
index c720256..5d6be45 100644
--- a/tests/format/symbol.py
+++ b/tests/format/symbol.py
@@ -24,3 +24,27 @@ class TestBinarySymbols(ChrysalideTestCase):
self.assertEqual(symbol.status, BinSymbol.SymbolStatus.INTERNAL)
self.assertEqual(str(symbol.status), 'SymbolStatus.INTERNAL')
+
+
+ def testSymbolComparison(self):
+ """Compare symbols and check the result."""
+
+ saddr = vmpa(0x100, vmpa.VMPA_NO_VIRTUAL)
+ srange = mrange(saddr, 0x3)
+ symbol0 = BinSymbol(BinSymbol.STP_ENTRY_POINT, srange)
+
+ saddr = vmpa(0x10, vmpa.VMPA_NO_VIRTUAL)
+ srange = mrange(saddr, 0x3)
+ symbol1 = BinSymbol(BinSymbol.STP_ENTRY_POINT, srange)
+
+ saddr = vmpa(0x100, vmpa.VMPA_NO_VIRTUAL)
+ srange = mrange(saddr, 0x30)
+ symbol2 = BinSymbol(BinSymbol.STP_ENTRY_POINT, srange)
+
+ self.assertTrue(symbol0 == symbol0)
+
+ self.assertTrue(symbol0 > symbol1)
+
+ self.assertTrue(symbol1 < symbol2)
+
+ self.assertTrue(symbol0 == symbol2)