本文整理汇总了Python中PyObjCTest.pythonnumber.OC_TestNumber类的典型用法代码示例。如果您正苦于以下问题:Python OC_TestNumber类的具体用法?Python OC_TestNumber怎么用?Python OC_TestNumber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_TestNumber类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testClasses
def testClasses(self):
# Ensure that python numbers are proxied using the right proxy type
for v in (0, 1, 2**32+1, 2**64+1, 42.5):
self.assert_(OC_TestNumber.numberClass_(v) is OC_PythonNumber)
# The booleans True and False must be proxied as the corresponding
# NSNumber constants, otherwise lowlevel Cocoa/CoreFoundation code
# get's upset.
boolClass = objc.lookUpClass('NSCFBoolean')
for v in (True, False):
self.assert_(OC_TestNumber.numberClass_(v) is boolClass)
self.assert_(objc.repythonify(v) is v)
示例2: testCompare
def testCompare(self):
self.assertEqual(OC_TestNumber.compareA_andB_(NSNumber.numberWithLong_(0), NSNumber.numberWithLong_(1)), NSOrderedAscending)
self.assertEqual(OC_TestNumber.compareA_andB_(NSNumber.numberWithLong_(0), NSNumber.numberWithUnsignedLongLong_(2**40)), NSOrderedAscending)
self.assertEqual(OC_TestNumber.compareA_andB_(NSNumber.numberWithLong_(0), NSNumber.numberWithDouble_(42.0)), NSOrderedAscending)
self.assertEqual(OC_TestNumber.compareA_andB_(NSNumber.numberWithLong_(0), NSNumber.numberWithLong_(-1)), NSOrderedDescending)
self.assertEqual(OC_TestNumber.compareA_andB_(NSNumber.numberWithLong_(0), NSNumber.numberWithLongLong_(-2**60)), NSOrderedDescending)
self.assertEqual(OC_TestNumber.compareA_andB_(NSNumber.numberWithLong_(0), NSNumber.numberWithDouble_(-42.0)), NSOrderedDescending)
self.assertEqual(OC_TestNumber.compareA_andB_(NSNumber.numberWithLong_(0), NSNumber.numberWithLong_(0)), NSOrderedSame)
self.assertEqual(OC_TestNumber.compareA_andB_(NSNumber.numberWithLong_(0), NSNumber.numberWithDouble_(0.0)), NSOrderedSame)
self.assertEqual(OC_TestNumber.compareA_andB_(NSNumber.numberWithLong_(0), NSNumber.numberWithLongLong_(0)), NSOrderedSame)
示例3: testNumberEqual
def testNumberEqual(self):
self.assert_(not OC_TestNumber.number_isEqualTo_(0, 1))
self.assert_(not OC_TestNumber.number_isEqualTo_(0, 2**64))
self.assert_(not OC_TestNumber.number_isEqualTo_(0, 42.0))
self.assert_(not OC_TestNumber.number_isEqualTo_(0, -1))
self.assert_(not OC_TestNumber.number_isEqualTo_(0, -2**64))
self.assert_(not OC_TestNumber.number_isEqualTo_(0, -42.0))
self.assert_(OC_TestNumber.number_isEqualTo_(0, 0))
self.assert_(OC_TestNumber.number_isEqualTo_(0, 0.0))
self.assert_(OC_TestNumber.number_isEqualTo_(0, long(0)))
示例4: testCompare
def testCompare(self):
self.assertEquals(OC_TestNumber.compareA_andB_(0, 1), NSOrderedAscending)
self.assertEquals(OC_TestNumber.compareA_andB_(0, 2**64), NSOrderedAscending)
self.assertEquals(OC_TestNumber.compareA_andB_(0, 42.0), NSOrderedAscending)
self.assertEquals(OC_TestNumber.compareA_andB_(0, -1), NSOrderedDescending)
self.assertEquals(OC_TestNumber.compareA_andB_(0, -2**64), NSOrderedDescending)
self.assertEquals(OC_TestNumber.compareA_andB_(0, -42.0), NSOrderedDescending)
self.assertEquals(OC_TestNumber.compareA_andB_(0, 0), NSOrderedSame)
self.assertEquals(OC_TestNumber.compareA_andB_(0, 0.0), NSOrderedSame)
self.assertEquals(OC_TestNumber.compareA_andB_(0, long(0)), NSOrderedSame)
示例5: testDescription
def testDescription(self):
v = OC_TestNumber.numberDescription_(NSNumber.numberWithInt_(0))
self.assertIsInstance(v, unicode)
self.assertEqual(v, "0")
v = OC_TestNumber.numberDescription_(NSNumber.numberWithLongLong_(2**60))
self.assertIsInstance(v, unicode)
self.assertEqual(v, unicode(str(2**60)))
v = OC_TestNumber.numberDescription_(NSNumber.numberWithLongLong_(-2**60))
self.assertIsInstance(v, unicode)
self.assertEqual(v, unicode(str(-2**60)))
v = OC_TestNumber.numberDescription_(NSNumber.numberWithDouble_(264.0))
self.assertIsInstance(v, unicode)
self.assertEqual(v, "264")
示例6: testNumberEqual
def testNumberEqual(self):
self.assertFalse(OC_TestNumber.number_isEqualTo_(0, 1))
self.assertFalse(OC_TestNumber.number_isEqualTo_(0, 2**64))
self.assertFalse(OC_TestNumber.number_isEqualTo_(0, 42.0))
self.assertFalse(OC_TestNumber.number_isEqualTo_(0, -1))
self.assertFalse(OC_TestNumber.number_isEqualTo_(0, -2**64))
self.assertFalse(OC_TestNumber.number_isEqualTo_(0, -42.0))
self.assertTrue(OC_TestNumber.number_isEqualTo_(0, 0))
self.assertTrue(OC_TestNumber.number_isEqualTo_(0, 0.0))
if sys.version_info[0] == 2:
self.assertTrue(OC_TestNumber.number_isEqualTo_(0, long(0)))
示例7: testMixedCompare
def testMixedCompare(self):
# compare for:
# - python number to nsnumber
# - nsnumber to python number
# For: (bool, int, long, float) vs (char, short, ...)
methods = [
'numberWithInt_',
'numberWithChar_',
'numberWithLong_',
'numberWithDouble_',
]
self.assertEqual(OC_TestNumber.compareA_andB_(42, 42), NSOrderedSame)
for m in methods:
self.assertEqual(OC_TestNumber.compareA_andB_(getattr(NSNumber, m)(42), 42), NSOrderedSame)
self.assertEqual(OC_TestNumber.compareA_andB_(42, getattr(NSNumber, m)(42)), NSOrderedSame)
self.assertEqual(OC_TestNumber.compareA_andB_(42, 99), NSOrderedAscending)
for m in methods:
self.assertEqual(OC_TestNumber.compareA_andB_(getattr(NSNumber, m)(42), 99), NSOrderedAscending)
self.assertEqual(OC_TestNumber.compareA_andB_(42, getattr(NSNumber, m)(99)), NSOrderedAscending)