mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-02 02:47:48 +02:00
Merge branch 'qt6'
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
# KLayout Layout Viewer
|
||||
# Copyright (C) 2006-2021 Matthias Koefferlein
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import testprep
|
||||
import klayout.QtCore5Compat as QtCore5Compat
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
# Tests the basic abilities of the module
|
||||
|
||||
class BasicTest(unittest.TestCase):
|
||||
|
||||
def test_1(self):
|
||||
self.assertEqual("QRegExp" in QtCore5Compat.__all__, True)
|
||||
|
||||
def test_2(self):
|
||||
# Some smoke test
|
||||
re = QtCore5Compat.QRegExp("a.*b")
|
||||
self.assertEqual(re.indexIn("xauby"), 1)
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestSuite()
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
|
||||
|
||||
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
# KLayout Layout Viewer
|
||||
# Copyright (C) 2006-2021 Matthias Koefferlein
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import testprep
|
||||
import klayout.QtCore as QtCore
|
||||
import klayout.QtWidgets as QtWidgets
|
||||
import klayout.QtGui as QtGui
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
# Tests the basic abilities of the module
|
||||
|
||||
class BasicTest(unittest.TestCase):
|
||||
|
||||
def test_1(self):
|
||||
self.assertEqual("QColor" in QtGui.__all__, True)
|
||||
self.assertEqual("QAction" in QtGui.__all__, True)
|
||||
|
||||
def test_2(self):
|
||||
# Some smoke test
|
||||
v = QtGui.QColor(12, 34, 68)
|
||||
self.assertEqual(v.red, 12)
|
||||
v.red = 17
|
||||
self.assertEqual(v.red, 17)
|
||||
self.assertEqual(v.green, 34)
|
||||
self.assertEqual(v.blue, 68)
|
||||
|
||||
trg = 0
|
||||
|
||||
def onTrigger(self):
|
||||
self.trg += 17
|
||||
|
||||
def test_3(self):
|
||||
app = QtWidgets.QApplication([ "progname" ])
|
||||
a = QtGui.QAction(None)
|
||||
a.text = "myaction"
|
||||
self.assertEqual(a.text, "myaction")
|
||||
self.trg = 0
|
||||
a.triggered = self.onTrigger
|
||||
a.trigger()
|
||||
self.assertEqual(self.trg, 17)
|
||||
a.trigger()
|
||||
self.assertEqual(self.trg, 34)
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestSuite()
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
|
||||
|
||||
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
# KLayout Layout Viewer
|
||||
# Copyright (C) 2006-2021 Matthias Koefferlein
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import testprep
|
||||
import klayout.QtCore as QtCore
|
||||
import klayout.QtGui as QtGui
|
||||
import klayout.QtWidgets as QtWidgets
|
||||
import klayout.QtSvg as QtSvg
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
# Tests the basic abilities of the module
|
||||
|
||||
class BasicTest(unittest.TestCase):
|
||||
|
||||
def test_1(self):
|
||||
self.assertEqual("QSvgRenderer" in QtSvg.__all__, True)
|
||||
|
||||
def test_2(self):
|
||||
# Smoke test
|
||||
q = QtSvg.QSvgRenderer()
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestSuite()
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
|
||||
|
||||
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
# KLayout Layout Viewer
|
||||
# Copyright (C) 2006-2021 Matthias Koefferlein
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import testprep
|
||||
import klayout.QtCore as QtCore
|
||||
import klayout.QtGui as QtGui
|
||||
import klayout.QtWidgets as QtWidgets
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
# Tests the basic abilities of the module
|
||||
|
||||
class BasicTest(unittest.TestCase):
|
||||
|
||||
def test_1(self):
|
||||
self.assertEqual("QGraphicsLineItem" in QtWidgets.__all__, True)
|
||||
|
||||
def test_2(self):
|
||||
i = QtWidgets.QGraphicsLineItem()
|
||||
i.line = QtCore.QLineF(1, 2, 3, 4)
|
||||
self.assertEqual(i.line.x1(), 1)
|
||||
self.assertEqual(i.line.y1(), 2)
|
||||
self.assertEqual(i.line.x2(), 3)
|
||||
self.assertEqual(i.line.y2(), 4)
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestSuite()
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
|
||||
|
||||
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
Vendored
+181
-10
@@ -2847,22 +2847,23 @@ class BasicTest(unittest.TestCase):
|
||||
self.assertEqual(sc.got_s0a, 0)
|
||||
self.assertEqual(sc.got_s0b, 0)
|
||||
|
||||
def test_74(self):
|
||||
def test_QByteArray(self):
|
||||
|
||||
# binary strings
|
||||
# QByteArray
|
||||
|
||||
if "ia_cref_to_qba" in pya.A.__dict__:
|
||||
|
||||
qba = pya.A.ia_cref_to_qba([ 17, 42, 0, 8 ])
|
||||
qba = pya.A.ia_cref_to_qba([ 16, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(qba), "bytearray(b'\\x11*\\x00\\x08')")
|
||||
self.assertEqual(repr(qba), "bytearray(b'\\x10*\\x00\\x08')")
|
||||
else:
|
||||
self.assertEqual(repr(qba), "b'\\x11*\\x00\\x08'")
|
||||
self.assertEqual(pya.A.qba_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qba_cref_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qba_cptr_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qba_ref_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qba_ptr_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qba), "b'\\x10*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.qba_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qba_cref_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qba_cptr_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qba_ref_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qba_ptr_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
|
||||
qba = pya.A.ia_cref_to_qba_cref([ 17, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
@@ -2870,8 +2871,161 @@ class BasicTest(unittest.TestCase):
|
||||
else:
|
||||
self.assertEqual(repr(qba), "b'\\x11*\\x00\\x08'")
|
||||
|
||||
qba = pya.A.ia_cref_to_qba_ref([ 18, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(qba), "bytearray(b'\\x12*\\x00\\x08')")
|
||||
else:
|
||||
self.assertEqual(repr(qba), "b'\\x12*\\x00\\x08'")
|
||||
|
||||
qba = pya.A.ia_cref_to_qba_cptr([ 19, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(qba), "bytearray(b'\\x13*\\x00\\x08')")
|
||||
else:
|
||||
self.assertEqual(repr(qba), "b'\\x13*\\x00\\x08'")
|
||||
|
||||
qba = pya.A.ia_cref_to_qba_ptr([ 20, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(qba), "bytearray(b'\\x14*\\x00\\x08')")
|
||||
else:
|
||||
self.assertEqual(repr(qba), "b'\\x14*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.qba_to_ia(b'\x00\x01\x02'), [ 0, 1, 2 ])
|
||||
|
||||
def test_QByteArrayView(self):
|
||||
|
||||
# QByteArrayView
|
||||
|
||||
if "ia_cref_to_qbav" in pya.A.__dict__:
|
||||
|
||||
qbav = pya.A.ia_cref_to_qbav([ 16, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(qbav), "bytearray(b'\\x10*\\x00\\x08')")
|
||||
else:
|
||||
self.assertEqual(repr(qbav), "b'\\x10*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.qbav_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qbav_cref_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qbav_cptr_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qbav_ref_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qbav_ptr_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
|
||||
qbav = pya.A.ia_cref_to_qbav_cref([ 17, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(qbav), "bytearray(b'\\x11*\\x00\\x08')")
|
||||
else:
|
||||
self.assertEqual(repr(qbav), "b'\\x11*\\x00\\x08'")
|
||||
|
||||
qbav = pya.A.ia_cref_to_qbav_ref([ 18, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(qbav), "bytearray(b'\\x12*\\x00\\x08')")
|
||||
else:
|
||||
self.assertEqual(repr(qbav), "b'\\x12*\\x00\\x08'")
|
||||
|
||||
qbav = pya.A.ia_cref_to_qbav_cptr([ 19, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(qbav), "bytearray(b'\\x13*\\x00\\x08')")
|
||||
else:
|
||||
self.assertEqual(repr(qbav), "b'\\x13*\\x00\\x08'")
|
||||
|
||||
qbav = pya.A.ia_cref_to_qbav_ptr([ 20, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(qbav), "bytearray(b'\\x14*\\x00\\x08')")
|
||||
else:
|
||||
self.assertEqual(repr(qbav), "b'\\x14*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.qbav_to_ia(b'\x00\x01\x02'), [ 0, 1, 2 ])
|
||||
|
||||
def test_QString(self):
|
||||
|
||||
# QString
|
||||
|
||||
if "ia_cref_to_qs" in pya.A.__dict__:
|
||||
|
||||
qs = pya.A.ia_cref_to_qs([ 16, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qs), "'\\x10*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.qs_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qs_cref_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qs_cptr_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qs_ref_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qs_ptr_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
|
||||
qs = pya.A.ia_cref_to_qs_cref([ 17, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qs), "'\\x11*\\x00\\x08'")
|
||||
|
||||
qs = pya.A.ia_cref_to_qs_ref([ 18, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qs), "'\\x12*\\x00\\x08'")
|
||||
|
||||
qs = pya.A.ia_cref_to_qs_cptr([ 19, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qs), "'\\x13*\\x00\\x08'")
|
||||
|
||||
qs = pya.A.ia_cref_to_qs_ptr([ 20, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qs), "'\\x14*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.qs_to_ia('\x00\x01\x02'), [ 0, 1, 2 ])
|
||||
|
||||
def test_QStringView(self):
|
||||
|
||||
# QStringView
|
||||
|
||||
if "ia_cref_to_qsv" in pya.A.__dict__:
|
||||
|
||||
qsv = pya.A.ia_cref_to_qsv([ 16, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qsv), "'\\x10*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.qsv_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qsv_cref_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qsv_cptr_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qsv_ref_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.qsv_ptr_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
|
||||
qsv = pya.A.ia_cref_to_qsv_cref([ 17, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qsv), "'\\x11*\\x00\\x08'")
|
||||
|
||||
qsv = pya.A.ia_cref_to_qsv_ref([ 18, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qsv), "'\\x12*\\x00\\x08'")
|
||||
|
||||
qsv = pya.A.ia_cref_to_qsv_cptr([ 19, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qsv), "'\\x13*\\x00\\x08'")
|
||||
|
||||
qsv = pya.A.ia_cref_to_qsv_ptr([ 20, 42, 0, 8 ])
|
||||
self.assertEqual(repr(qsv), "'\\x14*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.qsv_to_ia('\x00\x01\x02'), [ 0, 1, 2 ])
|
||||
|
||||
def test_QLatin1String(self):
|
||||
|
||||
# QLatin1String
|
||||
|
||||
if "ia_cref_to_ql1s" in pya.A.__dict__:
|
||||
|
||||
ql1s = pya.A.ia_cref_to_ql1s([ 16, 42, 0, 8 ])
|
||||
self.assertEqual(repr(ql1s), "'\\x10*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.ql1s_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.ql1s_cref_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.ql1s_cptr_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.ql1s_ref_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
self.assertEqual(pya.A.ql1s_ptr_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
|
||||
ql1s = pya.A.ia_cref_to_ql1s_cref([ 17, 42, 0, 8 ])
|
||||
self.assertEqual(repr(ql1s), "'\\x11*\\x00\\x08'")
|
||||
|
||||
ql1s = pya.A.ia_cref_to_ql1s_ref([ 18, 42, 0, 8 ])
|
||||
self.assertEqual(repr(ql1s), "'\\x12*\\x00\\x08'")
|
||||
|
||||
ql1s = pya.A.ia_cref_to_ql1s_cptr([ 19, 42, 0, 8 ])
|
||||
self.assertEqual(repr(ql1s), "'\\x13*\\x00\\x08'")
|
||||
|
||||
ql1s = pya.A.ia_cref_to_ql1s_ptr([ 20, 42, 0, 8 ])
|
||||
self.assertEqual(repr(ql1s), "'\\x14*\\x00\\x08'")
|
||||
|
||||
self.assertEqual(pya.A.ql1s_to_ia('\x00\x01\x02'), [ 0, 1, 2 ])
|
||||
|
||||
def test_binaryStrings(self):
|
||||
|
||||
# binary strings (non-Qt)
|
||||
|
||||
ba = pya.A.ia_cref_to_ba([ 17, 42, 0, 8 ])
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertEqual(repr(ba), "bytearray(b'\\x11*\\x00\\x08')")
|
||||
@@ -2891,8 +3045,25 @@ class BasicTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual(pya.A.ba_to_ia(b'\x00\x01\x02'), [ 0, 1, 2 ])
|
||||
|
||||
# Tests multi-base mixins (only constants and enums available)
|
||||
def test_multiBaseMixins(self):
|
||||
|
||||
bb = pya.BB() # base classes B1,B2,B3
|
||||
bb.set1(17) # B1
|
||||
self.assertEqual(bb.get1(), 17) # B1
|
||||
bb.set1(21) # B1
|
||||
|
||||
self.assertEqual(bb.get1(), 21) # B1
|
||||
self.assertEqual(pya.BB.C2, 17) # B2
|
||||
self.assertEqual(pya.BB.C3, -1) # B3
|
||||
self.assertEqual(pya.BB.E.E3B.to_i(), 101) # B3
|
||||
self.assertEqual(bb.d3(pya.BB.E.E3C, pya.BB.E.E3A), -2) # BB with B3 enums
|
||||
self.assertEqual(bb.d3(pya.BB.E.E3A, pya.BB.E.E3C), 2) # BB with B3 enums
|
||||
|
||||
# Custom factory implemented in Python
|
||||
|
||||
def test_80(self):
|
||||
|
||||
gc = pya.GObject.g_inst_count()
|
||||
gf = PyGFactory()
|
||||
go = pya.GFactory.create_f(gf, 17)
|
||||
|
||||
Vendored
+214
-19
@@ -2803,38 +2803,233 @@ class Basic_TestClass < TestBase
|
||||
|
||||
end
|
||||
|
||||
def test_74
|
||||
def test_QByteArray
|
||||
|
||||
# binary strings
|
||||
# QByteArray
|
||||
|
||||
qba = RBA::A::ia_cref_to_qba([ 17, 42, 0, 8 ])
|
||||
assert_equal(qba.inspect, "\"\\x11*\\x00\\b\"")
|
||||
assert_equal(RBA::A::qba_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qba_cref_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qba_cptr_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qba_ref_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qba_ptr_to_ia(qba), [ 17, 42, 0, 8 ])
|
||||
if RBA::A.respond_to?(:ia_cref_to_qba)
|
||||
|
||||
qba = RBA::A::ia_cref_to_qba_cref([ 17, 42, 0, 8 ])
|
||||
assert_equal(qba.inspect, "\"\\x11*\\x00\\b\"")
|
||||
qba = RBA::A::ia_cref_to_qba([ 16, 42, 0, 8 ])
|
||||
assert_equal(qba.inspect, "\"\\x10*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::qba_to_ia("\x00\x01\x02"), [ 0, 1, 2 ])
|
||||
assert_equal(RBA::A::qba_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qba_cref_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qba_cptr_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qba_ref_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qba_ptr_to_ia(qba), [ 16, 42, 0, 8 ])
|
||||
|
||||
ba = RBA::A::ia_cref_to_ba([ 17, 42, 0, 8 ])
|
||||
assert_equal(ba.inspect, "\"\\x11*\\x00\\b\"")
|
||||
assert_equal(RBA::A::ba_to_ia(ba), [ 17, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::ba_cref_to_ia(ba), [ 17, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::ba_cptr_to_ia(ba), [ 17, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::ba_ref_to_ia(ba), [ 17, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::ba_ptr_to_ia(ba), [ 17, 42, 0, 8 ])
|
||||
qba = RBA::A::ia_cref_to_qba_cref([ 17, 42, 0, 8 ])
|
||||
assert_equal(qba.inspect, "\"\\x11*\\x00\\b\"")
|
||||
qba = RBA::A::ia_cref_to_qba_ref([ 18, 42, 0, 8 ])
|
||||
assert_equal(qba.inspect, "\"\\x12*\\x00\\b\"")
|
||||
qba = RBA::A::ia_cref_to_qba_cptr([ 19, 42, 0, 8 ])
|
||||
assert_equal(qba.inspect, "\"\\x13*\\x00\\b\"")
|
||||
qba = RBA::A::ia_cref_to_qba_ptr([ 20, 42, 0, 8 ])
|
||||
assert_equal(qba.inspect, "\"\\x14*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::qba_to_ia("\x00\x01\x02"), [ 0, 1, 2 ])
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_QByteArrayView
|
||||
|
||||
# QByteArrayView
|
||||
|
||||
if RBA::A.respond_to?(:ia_cref_to_qbav)
|
||||
|
||||
qbav = RBA::A::ia_cref_to_qbav([ 16, 42, 0, 8 ])
|
||||
assert_equal(qbav.inspect, "\"\\x10*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::qbav_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qbav_cref_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qbav_cptr_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qbav_ref_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qbav_ptr_to_ia(qbav), [ 16, 42, 0, 8 ])
|
||||
|
||||
qbav = RBA::A::ia_cref_to_qbav_cref([ 17, 42, 0, 8 ])
|
||||
assert_equal(qbav.inspect, "\"\\x11*\\x00\\b\"")
|
||||
qbav = RBA::A::ia_cref_to_qbav_ref([ 18, 42, 0, 8 ])
|
||||
assert_equal(qbav.inspect, "\"\\x12*\\x00\\b\"")
|
||||
qbav = RBA::A::ia_cref_to_qbav_cptr([ 19, 42, 0, 8 ])
|
||||
assert_equal(qbav.inspect, "\"\\x13*\\x00\\b\"")
|
||||
qbav = RBA::A::ia_cref_to_qbav_ptr([ 20, 42, 0, 8 ])
|
||||
assert_equal(qbav.inspect, "\"\\x14*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::qbav_to_ia("\x00\x01\x02"), [ 0, 1, 2 ])
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_QString
|
||||
|
||||
# QString
|
||||
|
||||
if RBA::A.respond_to?(:ia_cref_to_qs)
|
||||
|
||||
qs = RBA::A::ia_cref_to_qs([ 16, 42, 0, 8 ])
|
||||
assert_equal(qs.inspect, "\"\\x10*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::qs_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qs_cref_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qs_cptr_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qs_ref_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qs_ptr_to_ia(qs), [ 16, 42, 0, 8 ])
|
||||
|
||||
qs = RBA::A::ia_cref_to_qs_cref([ 17, 42, 0, 8 ])
|
||||
assert_equal(qs.inspect, "\"\\x11*\\x00\\b\"")
|
||||
qs = RBA::A::ia_cref_to_qs_ref([ 18, 42, 0, 8 ])
|
||||
assert_equal(qs.inspect, "\"\\x12*\\x00\\b\"")
|
||||
qs = RBA::A::ia_cref_to_qs_cptr([ 19, 42, 0, 8 ])
|
||||
assert_equal(qs.inspect, "\"\\x13*\\x00\\b\"")
|
||||
qs = RBA::A::ia_cref_to_qs_ptr([ 20, 42, 0, 8 ])
|
||||
assert_equal(qs.inspect, "\"\\x14*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::qs_to_ia("\x00\x01\x02"), [ 0, 1, 2 ])
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_QLatin1String
|
||||
|
||||
# QLatin1String
|
||||
|
||||
if RBA::A.respond_to?(:ia_cref_to_ql1s)
|
||||
|
||||
ql1s = RBA::A::ia_cref_to_ql1s([ 16, 42, 0, 8 ])
|
||||
assert_equal(ql1s.inspect, "\"\\x10*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::ql1s_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::ql1s_cref_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::ql1s_cptr_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::ql1s_ref_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::ql1s_ptr_to_ia(ql1s), [ 16, 42, 0, 8 ])
|
||||
|
||||
ql1s = RBA::A::ia_cref_to_ql1s_cref([ 17, 42, 0, 8 ])
|
||||
assert_equal(ql1s.inspect, "\"\\x11*\\x00\\b\"")
|
||||
ql1s = RBA::A::ia_cref_to_ql1s_ref([ 18, 42, 0, 8 ])
|
||||
assert_equal(ql1s.inspect, "\"\\x12*\\x00\\b\"")
|
||||
ql1s = RBA::A::ia_cref_to_ql1s_cptr([ 19, 42, 0, 8 ])
|
||||
assert_equal(ql1s.inspect, "\"\\x13*\\x00\\b\"")
|
||||
ql1s = RBA::A::ia_cref_to_ql1s_ptr([ 20, 42, 0, 8 ])
|
||||
assert_equal(ql1s.inspect, "\"\\x14*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::ql1s_to_ia("\x00\x01\x02"), [ 0, 1, 2 ])
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_QStringView
|
||||
|
||||
# QStringView
|
||||
|
||||
if RBA::A.respond_to?(:ia_cref_to_qsv)
|
||||
|
||||
qsv = RBA::A::ia_cref_to_qsv([ 16, 42, 0, 8 ])
|
||||
assert_equal(qsv.inspect, "\"\\x10*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::qsv_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qsv_cref_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qsv_cptr_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qsv_ref_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
assert_equal(RBA::A::qsv_ptr_to_ia(qsv), [ 16, 42, 0, 8 ])
|
||||
|
||||
qsv = RBA::A::ia_cref_to_qsv_cref([ 17, 42, 0, 8 ])
|
||||
assert_equal(qsv.inspect, "\"\\x11*\\x00\\b\"")
|
||||
qsv = RBA::A::ia_cref_to_qsv_ref([ 18, 42, 0, 8 ])
|
||||
assert_equal(qsv.inspect, "\"\\x12*\\x00\\b\"")
|
||||
qsv = RBA::A::ia_cref_to_qsv_cptr([ 19, 42, 0, 8 ])
|
||||
assert_equal(qsv.inspect, "\"\\x13*\\x00\\b\"")
|
||||
qsv = RBA::A::ia_cref_to_qsv_ptr([ 20, 42, 0, 8 ])
|
||||
assert_equal(qsv.inspect, "\"\\x14*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::qsv_to_ia("\x00\x01\x02"), [ 0, 1, 2 ])
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_binaryStrings
|
||||
|
||||
# binary strings (non-Qt)
|
||||
|
||||
ba = RBA::A::ia_cref_to_ba([ 16, 42, 1, 8 ])
|
||||
assert_equal(ba.inspect, "\"\\x10*\\x01\\b\"")
|
||||
|
||||
assert_equal(RBA::A::ba_to_ia(ba), [ 16, 42, 1, 8 ])
|
||||
assert_equal(RBA::A::ba_cref_to_ia(ba), [ 16, 42, 1, 8 ])
|
||||
assert_equal(RBA::A::ba_cptr_to_ia(ba), [ 16, 42, 1, 8 ])
|
||||
assert_equal(RBA::A::ba_ref_to_ia(ba), [ 16, 42, 1, 8 ])
|
||||
assert_equal(RBA::A::ba_ptr_to_ia(ba), [ 16, 42, 1, 8 ])
|
||||
|
||||
ba = RBA::A::ia_cref_to_ba_cref([ 17, 42, 0, 8 ])
|
||||
assert_equal(ba.inspect, "\"\\x11*\\x00\\b\"")
|
||||
ba = RBA::A::ia_cref_to_ba_ref([ 18, 42, 0, 8 ])
|
||||
assert_equal(ba.inspect, "\"\\x12*\\x00\\b\"")
|
||||
ba = RBA::A::ia_cref_to_ba_cptr([ 19, 42, 0, 8 ])
|
||||
assert_equal(ba.inspect, "\"\\x13*\\x00\\b\"")
|
||||
ba = RBA::A::ia_cref_to_ba_ptr([ 20, 42, 0, 8 ])
|
||||
assert_equal(ba.inspect, "\"\\x14*\\x00\\b\"")
|
||||
|
||||
assert_equal(RBA::A::ba_to_ia("\x00\x01\x02"), [ 0, 1, 2 ])
|
||||
|
||||
end
|
||||
|
||||
def test_optional
|
||||
|
||||
if RBA::B.respond_to?(:int_to_optional)
|
||||
|
||||
assert_equal(RBA::B::int_to_optional(1, true), 1)
|
||||
assert_equal(RBA::B::int_to_optional(1, false), nil)
|
||||
assert_equal(RBA::B::int_to_optional_a(1, true).a1, 1)
|
||||
assert_equal(RBA::B::int_to_optional_a(1, false), nil)
|
||||
|
||||
assert_equal(RBA::B::optional_to_int(1, -1), 1)
|
||||
assert_equal(RBA::B::optional_to_int(nil, -1), -1)
|
||||
assert_equal(RBA::B::optional_cref_to_int(2, -1), 2)
|
||||
assert_equal(RBA::B::optional_cref_to_int(nil, -1), -1)
|
||||
assert_equal(RBA::B::optional_ref_to_int(3, -1), 3)
|
||||
assert_equal(RBA::B::optional_ref_to_int(nil, -1), -1)
|
||||
|
||||
assert_equal(RBA::B::optional_cptr_to_int(4, -1), 4)
|
||||
assert_equal(RBA::B::optional_ptr_to_int(5, -1), 5)
|
||||
|
||||
assert_equal(RBA::B::optional_a_to_int(RBA::A::new(1), -1), 1)
|
||||
assert_equal(RBA::B::optional_a_to_int(nil, -1), -1)
|
||||
assert_equal(RBA::B::optional_a_cref_to_int(RBA::A::new(2), -1), 2)
|
||||
assert_equal(RBA::B::optional_a_cref_to_int(nil, -1), -1)
|
||||
assert_equal(RBA::B::optional_a_ref_to_int(RBA::A::new(3), -1), 3)
|
||||
assert_equal(RBA::B::optional_a_ref_to_int(nil, -1), -1)
|
||||
|
||||
assert_equal(RBA::B::optional_a_cptr_to_int(RBA::A::new(4), -1), 4)
|
||||
assert_equal(RBA::B::optional_a_ptr_to_int(RBA::A::new(5), -1), 5)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Tests multi-base mixins (only constants and enums available)
|
||||
def test_multiBaseMixins
|
||||
|
||||
bb = RBA::BB::new # base classes B1,B2,B3
|
||||
bb.set1(17) # B1
|
||||
assert_equal(bb.get1, 17) # B1
|
||||
bb.set1(21) # B1
|
||||
assert_equal(RBA::B3::E::E3B.to_i, 101) # B3
|
||||
|
||||
assert_equal(bb.get1, 21) # B1
|
||||
assert_equal(RBA::BB::C2, 17) # B2
|
||||
assert_equal(RBA::BB::C3, -1) # B3
|
||||
assert_equal(RBA::BB::E::E3B.to_i, 101) # B3
|
||||
assert_equal(bb.d3(RBA::BB::E::E3C, RBA::BB::E::E3A), -2) # BB with B3 enums
|
||||
assert_equal(bb.d3(RBA::BB::E::E3A, RBA::BB::E::E3C), 2) # BB with B3 enums
|
||||
|
||||
end
|
||||
|
||||
# Custom factory implemented in Ruby
|
||||
def test_80
|
||||
|
||||
|
||||
Vendored
+1
@@ -235,6 +235,7 @@ RESULT
|
||||
assert_equal( menu.action( "file_menu.#3" ).is_checkable?, false )
|
||||
assert_equal( menu.action( "file_menu.#3" ).is_enabled?, false )
|
||||
|
||||
$a1.checked = false
|
||||
$a1.checkable = true;
|
||||
assert_equal( menu.action( "my_menu.new_item" ).is_visible?, false )
|
||||
assert_equal( menu.action( "my_menu.new_item" ).is_checked?, false )
|
||||
|
||||
Reference in New Issue
Block a user