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

Function test_seq_index

src/objects/sequence.rs:435–450  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

433
434 #[test]
435 fn test_seq_index() {
436 let gil = Python::acquire_gil();
437 let py = gil.python();
438 let v: Vec<i32> = vec![1, 1, 2, 3, 5, 8];
439 let seq = v
440 .to_py_object(py)
441 .into_object()
442 .cast_into::<PySequence>(py)
443 .unwrap();
444 assert_eq!(0, seq.index(py, 1i32).unwrap());
445 assert_eq!(2, seq.index(py, 2i32).unwrap());
446 assert_eq!(3, seq.index(py, 3i32).unwrap());
447 assert_eq!(4, seq.index(py, 5i32).unwrap());
448 assert_eq!(5, seq.index(py, 8i32).unwrap());
449 assert!(seq.index(py, 42i32).is_err());
450 }
451
452 #[test]
453 fn test_seq_count() {

Callers

nothing calls this directly

Calls 3

pythonMethod · 0.80
into_objectMethod · 0.45
to_py_objectMethod · 0.45

Tested by

no test coverage detected