MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / len

Function len

tests/test_class.rs:419–432  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

417
418#[test]
419fn 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
434py_class!(class Iterator |py| {
435 data iter: RefCell<Box<dyn iter::Iterator<Item=i32> + Send>>;

Callers 5

writeFunction · 0.85
operator_implFunction · 0.85
mainFunction · 0.85
check_symbols.pyFile · 0.85
test_emptyMethod · 0.85

Calls 1

pythonMethod · 0.80

Tested by

no test coverage detected