def test_valueWithRangePointer(self): range = opy.NSRange(10, 20) range_ptr = NSValue.valueWithPointer_(range) range_val_ptr = range_ptr.pointerValue() range_deref = dereference(range_val_ptr, of_type=opy.NSRange) self.assertEqual(range_deref.location, 10) self.assertEqual(range_deref.length, 20)
def test_objCType(self): rect = opy.NSRect(opy.NSPoint(3, 5), opy.NSSize(320, 480)) value_rect = NSValue.valueWithRect_(rect) self.assertEqual(value_rect.objCType(), b"{CGRect={CGPoint=dd}{CGSize=dd}}") range = opy.NSRange(5, 10) value_range = NSValue.valueWithRange_(range) self.assertEqual(value_range.objCType(), b"{_NSRange=QQ}")
def test_substringWithRange(self): text = N("some text") range = opy.NSRange(1, 3) self.assertEqual(text.substringWithRange_(range).UTF8String(), b"ome")
def test_valueWithRange(self): range = opy.NSRange(5, 10) value_range = NSValue.valueWithRange_(range) ret_range = value_range.rangeValue() self.assertEqual(ret_range.location, 5) self.assertEqual(ret_range.length, 10)
def test_lineRangeForRange(self): text = N("some text") range = opy.NSRange(0, 0) self.assertEqual(text.lineRangeForRange_(range).location, 0) self.assertEqual(text.lineRangeForRange_(range).length, 9)