()
| 417 | |
| 418 | #[test] |
| 419 | fn len() { |
| 420 | let gil = Python::acquire_gil(); |
| 421 | let py = gil.python(); |
| 422 | |
| 423 | let inst = Len::create_instance(py, 10).unwrap(); |
| 424 | py_assert!(py, inst, "len(inst) == 10"); |
| 425 | unsafe { |
| 426 | assert_eq!(ffi::PyObject_Size(inst.as_object().as_ptr()), 10); |
| 427 | assert_eq!(ffi::PyMapping_Size(inst.as_object().as_ptr()), 10); |
| 428 | } |
| 429 | |
| 430 | let inst = Len::create_instance(py, (isize::MAX as usize) + 1).unwrap(); |
| 431 | py_expect_exception!(py, inst, "len(inst)", OverflowError); |
| 432 | } |
| 433 | |
| 434 | py_class!(class Iterator |py| { |
| 435 | data iter: RefCell<Box<dyn iter::Iterator<Item=i32> + Send>>; |
no test coverage detected