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


Python OC_TestNumber.numberAsUnsignedLongLong_方法代码示例

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


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

示例1: testDoubleConversions

# 需要导入模块: from PyObjCTest.pythonnumber import OC_TestNumber [as 别名]
# 或者: from PyObjCTest.pythonnumber.OC_TestNumber import numberAsUnsignedLongLong_ [as 别名]
    def testDoubleConversions(self):
        v = 75.5

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsInt_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsLong_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsLongLong_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsUnsignedInt_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 75)
        self.assertEqual(OC_TestNumber.numberAsFloat_(v), 75.5)
        self.assertEqual(OC_TestNumber.numberAsDouble_(v), 75.5)

        # Negative values
        v = -127.6

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), -127)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), -127)
        self.assertEqual(OC_TestNumber.numberAsInt_(v), -127)
        self.assertEqual(OC_TestNumber.numberAsLong_(v), -127)
        self.assertEqual(OC_TestNumber.numberAsLongLong_(v), -127)

        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 129)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 65409)
        self.assertEqual(OC_TestNumber.numberAsUnsignedInt_(v), 4294967169)

        if sys.maxsize == (2 ** 31) -1:
            self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 4294967169)
        else:
            self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 18446744073709551489)

        if sys.byteorder == 'big':
            self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 4294967169)
        else:
            self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 18446744073709551489)

        self.assertEqual(OC_TestNumber.numberAsDouble_(v), -127.6)

        # Overflow
        v = float(2**64 + 99)

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)

        if sys.byteorder == 'big':
            self.assertEqual(OC_TestNumber.numberAsChar_(v), -1)
            self.assertEqual(OC_TestNumber.numberAsShort_(v), -1)
            self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 255)
            self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 65535)
        else:
            self.assertEqual(OC_TestNumber.numberAsChar_(v), 0)
            self.assertEqual(OC_TestNumber.numberAsShort_(v), 0)
            self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 0)
            self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 0)
开发者ID:GreatFruitOmsk,项目名称:pyobjc-core,代码行数:60,代码来源:test_number_proxy.py

示例2: testPythonIntConversions

# 需要导入模块: from PyObjCTest.pythonnumber import OC_TestNumber [as 别名]
# 或者: from PyObjCTest.pythonnumber.OC_TestNumber import numberAsUnsignedLongLong_ [as 别名]
    def testPythonIntConversions(self):
        # Conversions to other values. Note that values are converted
        # using C casts, without any exceptions when converting a
        # negative value to an unsigned one and without exceptions for
        # overflow.
        v = 42

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsInt_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsLongLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedInt_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsFloat_(v), 42.0)
        self.assertEqual(OC_TestNumber.numberAsDouble_(v), 42.0)

        # Negative values
        v = -42

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsInt_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsLong_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsLongLong_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 214)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 65494)
        self.assertEqual(OC_TestNumber.numberAsUnsignedInt_(v), 4294967254)

        if sys.maxsize == (2 ** 31) -1:
            self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 4294967254)
        else:
            self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 18446744073709551574)

        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 18446744073709551574)
        self.assertEqual(OC_TestNumber.numberAsFloat_(v), -42.0)
        self.assertEqual(OC_TestNumber.numberAsDouble_(v), -42.0)

        # Overflow
        v = 892455

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), 39)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), -25049)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 39)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 40487)
开发者ID:GreatFruitOmsk,项目名称:pyobjc-core,代码行数:54,代码来源:test_number_proxy.py

示例3: testIntConversions

# 需要导入模块: from PyObjCTest.pythonnumber import OC_TestNumber [as 别名]
# 或者: from PyObjCTest.pythonnumber.OC_TestNumber import numberAsUnsignedLongLong_ [as 别名]
    def testIntConversions(self):
        v = NSNumber.numberWithInt_(42)

        self.assertEqual(v.stringValue(), '42')

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsInt_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsLongLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedInt_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsFloat_(v), 42.0)
        self.assertEqual(OC_TestNumber.numberAsDouble_(v), 42.0)

        # Negative values
        v = NSNumber.numberWithInt_(-42)

        self.assertEqual(v.stringValue(), '-42')

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsInt_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsLong_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsLongLong_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 214)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 65494)
        self.assertEqual(OC_TestNumber.numberAsUnsignedInt_(v), 4294967254)

        if sys.maxsize == (2 ** 31) -1:
            self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 4294967254)
        else:
            self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 18446744073709551574)

        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 18446744073709551574)
        self.assertEqual(OC_TestNumber.numberAsFloat_(v), -42.0)
        self.assertEqual(OC_TestNumber.numberAsDouble_(v), -42.0)

        # Overflow
        v = NSNumber.numberWithInt_(892455)

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), 39)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), -25049)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 39)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 40487)
开发者ID:GreatFruitOmsk,项目名称:pyobjc-core,代码行数:53,代码来源:test_number_proxy.py

示例4: testShortConversions

# 需要导入模块: from PyObjCTest.pythonnumber import OC_TestNumber [as 别名]
# 或者: from PyObjCTest.pythonnumber.OC_TestNumber import numberAsUnsignedLongLong_ [as 别名]
    def testShortConversions(self):
        v = NSNumber.numberWithShort_(42)

        self.assertEquals(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEquals(OC_TestNumber.numberAsChar_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsShort_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsInt_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsLong_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsLongLong_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsUnsignedChar_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsUnsignedShort_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsUnsignedInt_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsUnsignedLong_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsUnsignedLongLong_(v), 42)
        self.assertEquals(OC_TestNumber.numberAsFloat_(v), 42.0)
        self.assertEquals(OC_TestNumber.numberAsDouble_(v), 42.0)
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:18,代码来源:test_number_proxy.py

示例5: testPythonLongConversions

# 需要导入模块: from PyObjCTest.pythonnumber import OC_TestNumber [as 别名]
# 或者: from PyObjCTest.pythonnumber.OC_TestNumber import numberAsUnsignedLongLong_ [as 别名]
    def testPythonLongConversions(self):
        if sys.version_info[0] == 2:
            v = long(42)
            self.assertIsInstance(v, long)
        else:
            v = 42

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsInt_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsLongLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedInt_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 42)
        self.assertEqual(OC_TestNumber.numberAsFloat_(v), 42.0)
        self.assertEqual(OC_TestNumber.numberAsDouble_(v), 42.0)

        # Negative values
        if sys.version_info[0] == 2:
            v = long(-42)
            self.assertIsInstance(v, long)
        else:
            v = -42

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsInt_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsLong_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsLongLong_(v), -42)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 214)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 65494)
        self.assertEqual(OC_TestNumber.numberAsUnsignedInt_(v), 4294967254)

        if sys.maxsize == (2 ** 31) -1:
            self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 4294967254)
        else:
            self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 18446744073709551574)

        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 18446744073709551574)
        self.assertEqual(OC_TestNumber.numberAsFloat_(v), -42.0)
        self.assertEqual(OC_TestNumber.numberAsDouble_(v), -42.0)

        # Overflow
        if sys.version_info[0] == 2:
            v = long(892455)
            self.assertIsInstance(v, long)
        else:
            v = 892455

        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), 39)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), -25049)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 39)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 40487)

        # Very much overflow
        v = 2 ** 64 + 1
        self.assertEqual(OC_TestNumber.numberAsBOOL_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsChar_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsShort_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsInt_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsLong_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsLongLong_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsUnsignedChar_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsUnsignedShort_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsUnsignedInt_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLong_(v), 1)
        self.assertEqual(OC_TestNumber.numberAsUnsignedLongLong_(v), 1)
开发者ID:GreatFruitOmsk,项目名称:pyobjc-core,代码行数:76,代码来源:test_number_proxy.py


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