pyuno/qa/pytests/embindtest.py | 156 ++++++++++++++++++++++++++ unotest/source/embindtest/embindtest.cxx | 182 +++++++++++++++++++++++++++++++ 2 files changed, 338 insertions(+)
New commits: commit f53a339292569d763be77ce41169d5f3a9a34e28 Author: Stephan Bergmann <[email protected]> AuthorDate: Thu Dec 11 08:57:12 2025 +0100 Commit: Stephan Bergmann <[email protected]> CommitDate: Thu Dec 11 16:24:41 2025 +0100 More exhaustive testing of PyUNO type mapping based on embindtest ...by implementing all the getSequence... variants that were left out of 3320b5fe2e3c696f3e0f2e301c922d89108f5c12 "Add exhaustive testing of PyUNO type mapping based on embindtest". Change-Id: Ia0dde7362484f83923999db68d80f57c7baa914c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195426 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/pyuno/qa/pytests/embindtest.py b/pyuno/qa/pytests/embindtest.py index 35c580edc3e6..783594a4cbd5 100644 --- a/pyuno/qa/pytests/embindtest.py +++ b/pyuno/qa/pytests/embindtest.py @@ -272,6 +272,162 @@ class Test(unohelper.Base, XTest): def isSequenceBoolean(self, value): return value == (True, True, False) + def getSequenceByte(self): + return (-12, 1, 12) + + def isSequenceByte(self, value): + return value == b'\xF4\x01\x0C' + + def getSequenceShort(self): + return (-1234, 1, 1234) + + def isSequenceShort(self, value): + return value == (-1234, 1, 1234) + + def getSequenceUnsignedShort(self): + return (1, 10, 54321) + + def isSequenceUnsignedShort(self, value): + return value == (1, 10, 54321) + + def getSequenceLong(self): + return (-123456, 1, 123456) + + def isSequenceLong(self, value): + return value == (-123456, 1, 123456) + + def getSequenceUnsignedLong(self): + return (1, 10, 3456789012) + + def isSequenceUnsignedLong(self, value): + return value == (1, 10, 3456789012) + + def getSequenceHyper(self): + return (-123456789, 1, 123456789) + + def isSequenceHyper(self, value): + return value == (-123456789, 1, 123456789) + + def getSequenceUnsignedHyper(self): + return (1, 10, 9876543210) + + def isSequenceUnsignedHyper(self, value): + return value == (1, 10, 9876543210) + + def getSequenceFloat(self): + return (-10.25, 1.5, 10.75) + + def isSequenceFloat(self, value): + return value == (-10.25, 1.5, 10.75) + + def getSequenceDouble(self): + return (-100.5, 1.25, 100.75) + + def isSequenceDouble(self, value): + return value == (-100.5, 1.25, 100.75) + + def getSequenceChar(self): + return ('a', 'B', 'Ö') + + def isSequenceChar(self, value): + return value == ('a', 'B', 'Ö') + + def getSequenceString(self): + return ('foo', 'barr', 'bazzz') + + def isSequenceString(self, value): + return value == ('foo', 'barr', 'bazzz') + + def getSequenceType(self): + return ( + uno.getTypeByName('long'), uno.getTypeByName('void'), + uno.getTypeByName('[]org.libreoffice.embindtest.Enum')) + + def isSequenceType(self, value): + return value == ( + uno.getTypeByName('long'), uno.getTypeByName('void'), + uno.getTypeByName('[]org.libreoffice.embindtest.Enum')) + + def getSequenceAny(self): + return (-123456, None, uno.Any('[]org.libreoffice.embindtest.Enum', (E_2, E3, E_10))) + + def isSequenceAny(self, value): + return value == (-123456, None, (E_2, E3, E_10)) + + def getSequenceSequenceString(self): + return ((), ('foo', 'barr'), ('baz',)) + + def isSequenceSequenceString(self, value): + return value == ((), ('foo', 'barr'), ('baz',)) + + def getSequenceEnum(self): + return (E_2, E3, E_10) + + def isSequenceEnum(self, value): + return value == (E_2, E3, E_10) + + def getSequenceStruct(self): + return ( + Struct( + True, -12, -1234, 1, -123456, 1, -123456789, 1, -10.25, -100.5, 'a', 'hä', + uno.getTypeByName('long'), -123456, (), E_2, StructLong(-123456), + uno.createUnoStruct( + 'org.libreoffice.embindtest.Template<' + 'any,org.libreoffice.embindtest.StructString>', + StructString('foo'), -123456, -123456, StructString('barr')), + self), + Struct( + True, 1, 1, 10, 1, 10, 1, 10, 1.5, 1.25, 'B', 'barr', uno.getTypeByName('void'), + None, ('foo', 'barr'), E3, StructLong(1), + uno.createUnoStruct( + 'org.libreoffice.embindtest.Template<' + 'any,org.libreoffice.embindtest.StructString>', + StructString('baz'), 1, None, StructString('foo')), + None), + Struct( + False, 12, 1234, 54321, 123456, 3456789012, 123456789, 9876543210, 10.75, 100.75, + 'Ö', 'bazzz', uno.getTypeByName('[]org.libreoffice.embindtest.Enum'), + uno.Any('[]org.libreoffice.embindtest.Enum', (E_2, E3, E_10)), ('baz',), E_10, + StructLong(123456), + uno.createUnoStruct( + 'org.libreoffice.embindtest.Template<' + 'any,org.libreoffice.embindtest.StructString>', + StructString('barr'), 123456, + uno.Any('[]org.libreoffice.embindtest.Enum', (E_2, E3, E_10)), + StructString('bazz')), + self)) + + def isSequenceStruct(self, value): + return value == ( + Struct( + True, -12, -1234, 1, -123456, 1, -123456789, 1, -10.25, -100.5, 'a', 'hä', + uno.getTypeByName('long'), -123456, (), E_2, StructLong(-123456), + uno.createUnoStruct( + 'org.libreoffice.embindtest.Template<' + 'any,org.libreoffice.embindtest.StructString>', + StructString('foo'), -123456, -123456, StructString('barr')), + self), + Struct( + True, 1, 1, 10, 1, 10, 1, 10, 1.5, 1.25, 'B', 'barr', uno.getTypeByName('void'), + None, ('foo', 'barr'), E3, StructLong(1), + uno.createUnoStruct( + 'org.libreoffice.embindtest.Template<' + 'any,org.libreoffice.embindtest.StructString>', + StructString('baz'), 1, None, StructString('foo')), + None), + Struct( + False, 12, 1234, 54321, 123456, 3456789012, 123456789, 9876543210, 10.75, 100.75, + 'Ö', 'bazzz', uno.getTypeByName('[]org.libreoffice.embindtest.Enum'), + uno.Any('[]org.libreoffice.embindtest.Enum', (E_2, E3, E_10)), ('baz',), E_10, + StructLong(123456), + uno.createUnoStruct( + 'org.libreoffice.embindtest.Template<' + 'any,org.libreoffice.embindtest.StructString>', + StructString('barr'), 123456, + uno.Any('[]org.libreoffice.embindtest.Enum', (E_2, E3, E_10)), + StructString('bazz')), + self)) + def getNull(self): return None diff --git a/unotest/source/embindtest/embindtest.cxx b/unotest/source/embindtest/embindtest.cxx index 8a7ccf1bbab7..51c28d7e801c 100644 --- a/unotest/source/embindtest/embindtest.cxx +++ b/unotest/source/embindtest/embindtest.cxx @@ -462,6 +462,188 @@ void doExecuteTest(css::uno::Reference<org::libreoffice::embindtest::XTest> cons bool const ok = test->isSequenceBoolean(val); verify(ok); } + { + auto const val = test->getSequenceByte(); + verify(val == css::uno::Sequence<sal_Int8>{ -12, 1, 12 }); + bool const ok = test->isSequenceByte(val); + verify(ok); + } + { + auto const val = test->getSequenceShort(); + verify(val == css::uno::Sequence<sal_Int16>{ -1234, 1, 1234 }); + bool const ok = test->isSequenceShort(val); + verify(ok); + } + { + auto const val = test->getSequenceUnsignedShort(); + verify(val == css::uno::Sequence<sal_uInt16>{ 1, 10, 54321 }); + bool const ok = test->isSequenceUnsignedShort(val); + verify(ok); + } + { + auto const val = test->getSequenceLong(); + verify(val == css::uno::Sequence<sal_Int32>{ -123456, 1, 123456 }); + bool const ok = test->isSequenceLong(val); + verify(ok); + } + { + auto const val = test->getSequenceUnsignedLong(); + verify(val == css::uno::Sequence<sal_uInt32>{ 1, 10, 3456789012 }); + bool const ok = test->isSequenceUnsignedLong(val); + verify(ok); + } + { + auto const val = test->getSequenceHyper(); + verify(val == css::uno::Sequence<sal_Int64>{ -123456789, 1, 123456789 }); + bool const ok = test->isSequenceHyper(val); + verify(ok); + } + { + auto const val = test->getSequenceUnsignedHyper(); + verify(val == css::uno::Sequence<sal_uInt64>{ 1, 10, 9876543210 }); + bool const ok = test->isSequenceUnsignedHyper(val); + verify(ok); + } + { + auto const val = test->getSequenceFloat(); + verify(val == css::uno::Sequence<float>{ -10.25, 1.5, 10.75 }); + bool const ok = test->isSequenceFloat(val); + verify(ok); + } + { + auto const val = test->getSequenceDouble(); + verify(val == css::uno::Sequence<double>{ -100.5, 1.25, 100.75 }); + bool const ok = test->isSequenceDouble(val); + verify(ok); + } + { + auto const val = test->getSequenceChar(); + verify(val == css::uno::Sequence<sal_Unicode>{ 'a', 'B', u'Ö' }); + bool const ok = test->isSequenceChar(val); + verify(ok); + } + { + auto const val = test->getSequenceString(); + verify(val == css::uno::Sequence<OUString>{ u"foo"_ustr, u"barr"_ustr, u"bazzz"_ustr }); + bool const ok = test->isSequenceString(val); + verify(ok); + } + { + auto const val = test->getSequenceType(); + verify( + val + == css::uno::Sequence<css::uno::Type>{ + cppu::UnoType<sal_Int32>::get(), cppu::UnoType<void>::get(), + cppu::UnoType<css::uno::Sequence<org::libreoffice::embindtest::Enum>>::get() }); + bool const ok = test->isSequenceType(val); + verify(ok); + } + { + auto const val = test->getSequenceAny(); + verify(val + == css::uno::Sequence<css::uno::Any>{ + css::uno::Any(-123456), css::uno::Any(), + css::uno::Any(css::uno::Sequence<org::libreoffice::embindtest::Enum>{ + org::libreoffice::embindtest::Enum_E_2, + org::libreoffice::embindtest::Enum_E3, + org::libreoffice::embindtest::Enum_E_10 }) }); + bool const ok = test->isSequenceAny(val); + verify(ok); + } + { + auto const val = test->getSequenceSequenceString(); + verify(val + == css::uno::Sequence<css::uno::Sequence<OUString>>{ + {}, { u"foo"_ustr, u"barr"_ustr }, { u"baz"_ustr } }); + bool const ok = test->isSequenceSequenceString(val); + verify(ok); + } + { + auto const val = test->getSequenceEnum(); + verify(val + == css::uno::Sequence<org::libreoffice::embindtest::Enum>{ + org::libreoffice::embindtest::Enum_E_2, org::libreoffice::embindtest::Enum_E3, + org::libreoffice::embindtest::Enum_E_10 }); + bool const ok = test->isSequenceEnum(val); + verify(ok); + } + { + auto const val = test->getSequenceStruct(); + verify( + val + == css::uno::Sequence<org::libreoffice::embindtest::Struct>{ + { true, + -12, + -1234, + 1, + -123456, + 1, + -123456789, + 1, + -10.25, + -100.5, + 'a', + u"hä"_ustr, + cppu::UnoType<sal_Int32>::get(), + css::uno::Any(sal_Int32(-123456)), + {}, + org::libreoffice::embindtest::Enum_E_2, + { -123456 }, + { { u"foo"_ustr }, + -123456, + css::uno::Any(sal_Int32(-123456)), + { u"barr"_ustr } }, + test }, + { true, + 1, + 1, + 10, + 1, + 10, + 1, + 10, + 1.5, + 1.25, + 'B', + u"barr"_ustr, + cppu::UnoType<void>::get(), + css::uno::Any(), + { u"foo"_ustr, u"barr"_ustr }, + org::libreoffice::embindtest::Enum_E3, + { 1 }, + { { u"baz"_ustr }, 1, css::uno::Any(), { u"foo"_ustr } }, + nullptr }, + { false, + 12, + 1234, + 54321, + 123456, + 3456789012, + 123456789, + 9876543210, + 10.75, + 100.75, + u'Ö', + u"bazzz"_ustr, + cppu::UnoType<css::uno::Sequence<org::libreoffice::embindtest::Enum>>::get(), + css::uno::Any(css::uno::Sequence<org::libreoffice::embindtest::Enum>{ + org::libreoffice::embindtest::Enum_E_2, + org::libreoffice::embindtest::Enum_E3, + org::libreoffice::embindtest::Enum_E_10 }), + { u"baz"_ustr }, + org::libreoffice::embindtest::Enum_E_10, + { 123456 }, + { { u"barr"_ustr }, + 123456, + css::uno::Any(css::uno::Sequence<org::libreoffice::embindtest::Enum>{ + org::libreoffice::embindtest::Enum_E_2, + org::libreoffice::embindtest::Enum_E3, + org::libreoffice::embindtest::Enum_E_10 }), + { u"bazz"_ustr } }, + test } }); + bool const ok = test->isSequenceStruct(val); + verify(ok); + } { auto const val = test->getNull(); verify(val == css::uno::Reference<org::libreoffice::embindtest::XTest>());
