diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-05-26 08:10:11 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-06-06 15:54:32 +0200 |
| commit | 135c10324b1533f23f34a043963ce49b324c16c0 (patch) | |
| tree | acfdb440b718d86d66aeb2ed63e635c3e1ed15f3 /sources/shiboken6/tests/smartbinding/std_optional_test.py | |
| parent | 2365c9bec8d03fe00b9153848adc6a474c3ff945 (diff) | |
shiboken6: Add a test for automatic conversion from T to std::optional<T>
Task-number: PYSIDE-3107
Change-Id: I63f182eebba887780bfa882aebc653c60e07d9ad
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/tests/smartbinding/std_optional_test.py')
| -rw-r--r-- | sources/shiboken6/tests/smartbinding/std_optional_test.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/smartbinding/std_optional_test.py b/sources/shiboken6/tests/smartbinding/std_optional_test.py index cd97facfa..9e8bc8d47 100644 --- a/sources/shiboken6/tests/smartbinding/std_optional_test.py +++ b/sources/shiboken6/tests/smartbinding/std_optional_test.py @@ -26,6 +26,15 @@ def integer_from_value(v): class StdOptionalTests(unittest.TestCase): + def testConversionFromInt(self): + """PYSIDE-3107: Test whether a parameter taking a 'std::optional<int>' + accepts 'int'.""" + b = StdOptionalTestBench() + b.setOptionalInt(43) + self.assertEqual(b.optionalInt().value(), 43) + b.setOptionalInt(None) + self.assertFalse(b.optionalInt().has_value()) + def testCInt(self): b = StdOptionalTestBench() ci = b.optionalInt() |
