本文整理汇总了Python中PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs类的典型用法代码示例。如果您正苦于以下问题:Python Py_MetaDataTest_AllArgs类的具体用法?Python Py_MetaDataTest_AllArgs怎么用?Python Py_MetaDataTest_AllArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Py_MetaDataTest_AllArgs类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testWithCount
def testWithCount(self):
o = Py_MetaDataTest_AllArgs.new()
v = o.fillArray_count_(3)
self.assertEquals(list(v), [10, 11, 12])
v = o.fillArray_count_(None, 3)
self.assertEquals(list(v), [10, 11, 12])
v = o.fillArray_count_(5)
self.assertEquals(list(v), [10, 11, 12, 13, 14])
v = o.fillArray_count_(0)
self.assertEquals(list(v), [])
#self.assertRaises(ValueError, o.fillArray_count_, objc.NULL, 0)
n, v = o.nullfillArray_count_(3)
self.assertEquals(n, 2)
self.assertEquals(list(v), [30,31,32])
n, v = o.nullfillArray_count_(None, 3)
self.assertEquals(n, 2)
self.assertEquals(list(v), [30,31,32])
n, v = o.nullfillArray_count_(objc.NULL, 3)
self.assertEquals(n, 1)
示例2: testInput
def testInput(self):
o = Py_MetaDataTest_AllArgs.new()
r = o.sumX_andY_(1, 2)
self.assertEquals(r, 1**2+2**2)
r = o.sumX_andY_(2535, 5325)
self.assertEquals(r, 2535**2 + 5325**2)
示例3: testFixedSize
def testFixedSize(self):
o = Py_MetaDataTest_AllArgs.new()
v = o.makeIntArrayOf5()
self.assertEquals( len(v), 5 )
self.assertEquals( list(v), [100, 200, 300, 400, 500] )
v = o.nullIntArrayOf5()
self.assertEquals(v, objc.NULL)
示例4: testNULLterminated
def testNULLterminated(self):
o = Py_MetaDataTest_AllArgs.new()
v = o.makeStringArray()
self.assertEquals(len(v), 3)
self.assertEquals(list(v), [ b"jaap", b"pieter", b"hans" ])
v = o.nullStringArray()
self.assertEquals(v, objc.NULL)
示例5: testOutput
def testOutput(self):
o = Py_MetaDataTest_AllArgs.new()
div, rem = o.divBy5_remainder_(55)
self.assertEquals(div, 55 / 7)
self.assertEquals(rem, 55 % 7)
div, rem = o.divBy5_remainder_(13)
self.assertEquals(div, 13 / 7)
self.assertEquals(rem, 13 % 7)
示例6: testWithCountInResult
def testWithCountInResult(self):
o = Py_MetaDataTest_AllArgs.new()
c, v = o.fillArray_uptoCount_(20)
self.assertEquals(c, 10)
self.assertEquals(list(v), [i+10 for i in range(10)])
c, v = o.maybeFillArray_()
self.assertEquals(c, 2)
self.assertEquals(list(v), [0, 1])
示例7: testSizeInArgument
def testSizeInArgument(self):
o = Py_MetaDataTest_AllArgs.new()
v = o.makeIntArrayOf_(3)
self.assertEquals(len(v), 3)
self.assertEquals(list(v), [20, 21, 22])
v = o.makeIntArrayOf_(10)
self.assertEquals(len(v), 10)
self.assertEquals(list(v), list(range(20, 30)))
v = o.nullIntArrayOf_(100)
self.assertEquals(v, objc.NULL)
示例8: testNullAccepted
def testNullAccepted(self):
# Note: the commented-out test-cases require a change in the pyobjc-core
o = Py_MetaDataTest_AllArgs.new();
def makeNum(value):
return int(value, 0)
# All arguments present
r, y, z = o.input_output_inputAndOutput_(1, 2)
self.assertEquals(len(r), 3)
self.assertEquals(len(filter(lambda x: x is not objc.NULL, r)), 3)
self.assertEquals(y, 9)
self.assertEquals(z, 10)
r, y, z = o.input_output_inputAndOutput_(1, None, 2)
self.assertEquals(len(r), 3)
self.assertEquals(len(filter(lambda x: x is not objc.NULL, r)), 3)
self.assertEquals(y, 9)
self.assertEquals(z, 10)
# Argument 1 is NULL
r, y, z = o.input_output_inputAndOutput_(objc.NULL, 2)
self.assertEquals(len(r), 3)
self.assertEquals(len(filter(lambda x: x is not objc.NULL, r)), 2)
self.assertEquals(y, 11)
self.assertEquals(z, 12)
r, y, z = o.input_output_inputAndOutput_(objc.NULL, None, 2)
self.assertEquals(len(r), 3)
self.assertEquals(len(filter(lambda x: x is not objc.NULL, r)), 2)
self.assertEquals(y, 11)
self.assertEquals(z, 12)
# Argument 2 is NULL
r, y, z = o.input_output_inputAndOutput_(1, objc.NULL, 2)
self.assertEquals(len(r), 3)
self.assertEquals(len(filter(lambda x: x is not objc.NULL, r)), 2)
self.assertEquals(y, 13) # objc.NULL ...
self.assertEquals(z, 14)
# Argument 3 is NULL
r, y, z = o.input_output_inputAndOutput_(1, objc.NULL)
self.assertEquals(len(r), 3)
self.assertEquals(len(filter(lambda x: x is not objc.NULL, r)), 2)
self.assertEquals(y, 15)
self.assertEquals(z, 16) # objc.NULL ...
r, y, z = o.input_output_inputAndOutput_(1, None, objc.NULL)
self.assertEquals(len(r), 3)
self.assertEquals(len(filter(lambda x: x is not objc.NULL, r)), 2)
self.assertEquals(y, 15)
self.assertEquals(z, 16) # , objc.NULL)
示例9: testNullTerminated
def testNullTerminated(self):
o = Py_MetaDataTest_AllArgs.new()
# Output only arrays of null-terminated arrays cannot be
# wrapped automaticly. How is the bridge supposed to know
# how much memory it should allocate for the C-array?
#self.assertRaises(TypeError, o.fillStringArray_)
#self.assertRaises(TypeError, o.fillStringArray_, None)
#self.assertRaises(ValueError, o.fillStringArray_, objc.NULL)
#self.assertRaises(TypeError, o.nullfillStringArray_)
#self.assertRaises(TypeError, o.nullfillStringArray_, None)
n, v = o.nullfillStringArray_(objc.NULL)
self.assertEquals(n, 9)
self.assertIs(v, objc.NULL)
示例10: testInputOutput
def testInputOutput(self):
o = Py_MetaDataTest_AllArgs.new()
x, y = o.swapX_andY_(42, 284)
self.assertEquals(x, 284*2)
self.assertEquals(y, 42*2)