aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/samplebinding
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/tests/samplebinding')
-rw-r--r--sources/shiboken6/tests/samplebinding/CMakeLists.txt1
-rw-r--r--sources/shiboken6/tests/samplebinding/spaceship_test.py18
-rw-r--r--sources/shiboken6/tests/samplebinding/typesystem_sample.xml1
3 files changed, 19 insertions, 1 deletions
diff --git a/sources/shiboken6/tests/samplebinding/CMakeLists.txt b/sources/shiboken6/tests/samplebinding/CMakeLists.txt
index c9e4f601f..01f51fc2d 100644
--- a/sources/shiboken6/tests/samplebinding/CMakeLists.txt
+++ b/sources/shiboken6/tests/samplebinding/CMakeLists.txt
@@ -64,6 +64,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/moveonly_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/moveonlyhandler_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/noimplicitconversion_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/nondefaultctor_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/nonequalitycomparisontester_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objectmodel_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttype_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypebyvalue_wrapper.cpp
diff --git a/sources/shiboken6/tests/samplebinding/spaceship_test.py b/sources/shiboken6/tests/samplebinding/spaceship_test.py
index 92d65d4ee..95d2506ce 100644
--- a/sources/shiboken6/tests/samplebinding/spaceship_test.py
+++ b/sources/shiboken6/tests/samplebinding/spaceship_test.py
@@ -14,7 +14,8 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from shiboken_paths import init_paths
init_paths()
-from sample import FreeSpaceshipComparisonTester, SpaceshipComparisonTester
+from sample import (FreeSpaceshipComparisonTester, SpaceshipComparisonTester,
+ NonEqualityComparisonTester)
class SpaceshipTest(unittest.TestCase):
@@ -31,6 +32,12 @@ class SpaceshipTest(unittest.TestCase):
self.assertFalse(t1 > t2)
@unittest.skipUnless(SpaceshipComparisonTester.Enabled.HasSpaceshipOperator, "< C++ 20")
+ def testNonHomogeneousSpaceshipOperator(self):
+ t = SpaceshipComparisonTester(42)
+ self.assertTrue(t < 43)
+ self.assertTrue(t > 41)
+
+ @unittest.skipUnless(SpaceshipComparisonTester.Enabled.HasSpaceshipOperator, "< C++ 20")
def testFreeSpaceshipOperator(self):
"""Test a free operator<=>(). It does not provide equality
as it is not defaulted."""
@@ -39,6 +46,15 @@ class SpaceshipTest(unittest.TestCase):
self.assertTrue(t1 < t2)
self.assertFalse(t1 > t2)
+ @unittest.skipUnless(SpaceshipComparisonTester.Enabled.HasSpaceshipOperator, "< C++ 20")
+ def testNonEqualSynthetization(self):
+ ne_a = NonEqualityComparisonTester(1)
+ ne_b = NonEqualityComparisonTester(1)
+ self.assertTrue(ne_a == ne_b)
+ # Verify that different instances with same value are not reported as "not equal",
+ # (fooling the FallbackRichCompare() function which is generated for missing operators).
+ self.assertFalse(ne_a != ne_b)
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml
index fed84ba0d..05798a6ce 100644
--- a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml
@@ -160,6 +160,7 @@
<enum-type name="Enabled"/>
</value-type>
<value-type name="FreeSpaceshipComparisonTester"/>
+ <value-type name="NonEqualityComparisonTester"/>
<primitive-type name="PStr">
<include file-name="str.h" location="global"/>