当前位置: 首页>>代码示例>>Python>>正文


Python Py_MetaDataTest_AllArgs.new方法代码示例

本文整理汇总了Python中PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs.new方法的典型用法代码示例。如果您正苦于以下问题:Python Py_MetaDataTest_AllArgs.new方法的具体用法?Python Py_MetaDataTest_AllArgs.new怎么用?Python Py_MetaDataTest_AllArgs.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs的用法示例。


在下文中一共展示了Py_MetaDataTest_AllArgs.new方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testWithCount

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
    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)
开发者ID:aosm,项目名称:pyobjc,代码行数:28,代码来源:test_metadata_py2py.py

示例2: testInput

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
    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)
开发者ID:aosm,项目名称:pyobjc,代码行数:10,代码来源:test_metadata_py2py.py

示例3: testFixedSize

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
    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)
开发者ID:aosm,项目名称:pyobjc,代码行数:11,代码来源:test_metadata_py2py.py

示例4: testNULLterminated

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
    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)
开发者ID:aosm,项目名称:pyobjc,代码行数:11,代码来源:test_metadata_py2py.py

示例5: testOutput

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
    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)
开发者ID:aosm,项目名称:pyobjc,代码行数:12,代码来源:test_metadata_py2py.py

示例6: testWithCountInResult

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
    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])
开发者ID:aosm,项目名称:pyobjc,代码行数:12,代码来源:test_metadata_py2py.py

示例7: testSizeInArgument

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
    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)
开发者ID:aosm,项目名称:pyobjc,代码行数:14,代码来源:test_metadata_py2py.py

示例8: testNullAccepted

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
    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)
开发者ID:aosm,项目名称:pyobjc,代码行数:54,代码来源:test_metadata_py2py.py

示例9: testNullTerminated

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
    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)
开发者ID:aosm,项目名称:pyobjc,代码行数:18,代码来源:test_metadata_py2py.py

示例10: testInputOutput

# 需要导入模块: from PyObjCTest.test_metadata_py import Py_MetaDataTest_AllArgs [as 别名]
# 或者: from PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs import new [as 别名]
 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)
开发者ID:aosm,项目名称:pyobjc,代码行数:7,代码来源:test_metadata_py2py.py


注:本文中的PyObjCTest.test_metadata_py.Py_MetaDataTest_AllArgs.new方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。