(self)
| 283 | self.check_long_asint(as_size_t, 0, SIZE_MAX, use_index=False) |
| 284 | |
| 285 | def test_long_asdouble(self): |
| 286 | # Test PyLong_AsDouble() |
| 287 | asdouble = _testlimitedcapi.pylong_asdouble |
| 288 | MAX = int(sys.float_info.max) |
| 289 | for value in (-MAX, MAX, -1, 0, 1, 1234): |
| 290 | with self.subTest(value=value): |
| 291 | self.assertEqual(asdouble(value), float(value)) |
| 292 | self.assertIsInstance(asdouble(value), float) |
| 293 | |
| 294 | self.assertEqual(asdouble(IntSubclass(42)), 42.0) |
| 295 | self.assertRaises(TypeError, asdouble, Index(42)) |
| 296 | self.assertRaises(TypeError, asdouble, MyIndexAndInt()) |
| 297 | |
| 298 | self.assertRaises(OverflowError, asdouble, 2 * MAX) |
| 299 | self.assertRaises(OverflowError, asdouble, -2 * MAX) |
| 300 | self.assertRaises(TypeError, asdouble, 1.0) |
| 301 | self.assertRaises(TypeError, asdouble, b'2') |
| 302 | self.assertRaises(TypeError, asdouble, '3') |
| 303 | self.assertRaises(SystemError, asdouble, NULL) |
| 304 | |
| 305 | def test_long_asvoidptr(self): |
| 306 | # Test PyLong_AsVoidPtr() |
nothing calls this directly
no test coverage detected