Test reverse

This commit is contained in:
Remco Bloemen 2020-11-19 11:27:48 -08:00 committed by Crozet Sébastien
parent 73d6ba0ca1
commit dd31f09105
1 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,7 @@ use na::{
#[test] #[test]
fn iter() { fn iter() {
let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
dbg!(a);
let mut it = a.iter(); let mut it = a.iter();
assert_eq!(*it.next().unwrap(), 1.0); assert_eq!(*it.next().unwrap(), 1.0);
@ -30,6 +31,15 @@ fn iter() {
assert_eq!(*it.next().unwrap(), 2.0); assert_eq!(*it.next().unwrap(), 2.0);
assert!(it.next().is_none()); assert!(it.next().is_none());
let mut it = a.iter().rev();
assert_eq!(*it.next().unwrap(), 6.0);
assert_eq!(*it.next().unwrap(), 3.0);
assert_eq!(*it.next().unwrap(), 5.0);
assert_eq!(*it.next().unwrap(), 2.0);
assert_eq!(*it.next().unwrap(), 4.0);
assert_eq!(*it.next().unwrap(), 1.0);
assert!(it.next().is_none());
let row = a.row(0); let row = a.row(0);
let mut it = row.iter(); let mut it = row.iter();
assert_eq!(*it.next().unwrap(), 1.0); assert_eq!(*it.next().unwrap(), 1.0);