aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2025-12-01 19:58:24 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2025-12-03 12:53:14 +0100
commit7647b5052968f6fa2de04e8f744c697844d5b275 (patch)
tree6f5f9b395b54afc4128a44df0010656258ae9712
parentcda6f0d89bf70102891c4214cc496e10d11e856f (diff)
shiboken6: Add tests for non-homogeneous comparison
Task-number: PYSIDE-3245 Change-Id: I84bac9ef5afdbb4356884a7933ed8209d886d836 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/shiboken6/tests/libsample/intwrapper.h9
-rw-r--r--sources/shiboken6/tests/samplebinding/intwrapper_test.py7
2 files changed, 16 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/libsample/intwrapper.h b/sources/shiboken6/tests/libsample/intwrapper.h
index cfda5adc7..e1212cadf 100644
--- a/sources/shiboken6/tests/libsample/intwrapper.h
+++ b/sources/shiboken6/tests/libsample/intwrapper.h
@@ -32,6 +32,15 @@ public:
friend constexpr inline bool operator>=(IntWrapper lhs, IntWrapper rhs) noexcept
{ return lhs.m_number >= rhs.m_number; }
+ friend constexpr inline bool operator==(IntWrapper lhs, int v) noexcept
+ { return lhs.m_number == v; }
+ friend constexpr inline bool operator==(int v, IntWrapper lhs) noexcept
+ { return v == lhs.m_number; }
+ friend constexpr inline bool operator!=(IntWrapper lhs, int v) noexcept
+ { return lhs.m_number != v; }
+ friend constexpr inline bool operator!=(int v, IntWrapper lhs) noexcept
+ { return v != lhs.m_number; }
+
constexpr inline IntWrapper &operator+=(IntWrapper i);
constexpr inline IntWrapper &operator-=(const IntWrapper i);
diff --git a/sources/shiboken6/tests/samplebinding/intwrapper_test.py b/sources/shiboken6/tests/samplebinding/intwrapper_test.py
index 04b2ff351..dc703b0e7 100644
--- a/sources/shiboken6/tests/samplebinding/intwrapper_test.py
+++ b/sources/shiboken6/tests/samplebinding/intwrapper_test.py
@@ -30,6 +30,13 @@ class IntWrapperTest(unittest.TestCase):
i -= ten2
self.assertTrue(i == ten1)
+ def testNonHomogeneousComparison(self):
+ ten = IntWrapper(10)
+ self.assertTrue(ten == 10)
+ self.assertTrue(ten != 11)
+ self.assertTrue(10 == ten)
+ self.assertTrue(11 != ten)
+
def testAddPyMethodDef(self):
"""Test of added free function (PYSIDE-1905)."""
i = IntWrapper(10)