Test the whole chunks instead of just an element in the chunks/chunks_mut tests
Easy enough to do and ensures that the whole chunk is as expected instead of just the element that was looked at before.
This commit is contained in:
parent
baa81dc77f
commit
ed774838b3
@ -117,12 +117,12 @@ fn test_chunks_count() {
|
||||
fn test_chunks_nth() {
|
||||
let v: &[i32] = &[0, 1, 2, 3, 4, 5];
|
||||
let mut c = v.chunks(2);
|
||||
assert_eq!(c.nth(1).unwrap()[1], 3);
|
||||
assert_eq!(c.next().unwrap()[0], 4);
|
||||
assert_eq!(c.nth(1).unwrap(), &[2, 3]);
|
||||
assert_eq!(c.next().unwrap(), &[4, 5]);
|
||||
|
||||
let v2: &[i32] = &[0, 1, 2, 3, 4];
|
||||
let mut c2 = v2.chunks(3);
|
||||
assert_eq!(c2.nth(1).unwrap()[1], 4);
|
||||
assert_eq!(c2.nth(1).unwrap(), &[3, 4]);
|
||||
assert_eq!(c2.next(), None);
|
||||
}
|
||||
|
||||
@ -168,12 +168,12 @@ fn test_chunks_mut_count() {
|
||||
fn test_chunks_mut_nth() {
|
||||
let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
|
||||
let mut c = v.chunks_mut(2);
|
||||
assert_eq!(c.nth(1).unwrap()[1], 3);
|
||||
assert_eq!(c.next().unwrap()[0], 4);
|
||||
assert_eq!(c.nth(1).unwrap(), &[2, 3]);
|
||||
assert_eq!(c.next().unwrap(), &[4, 5]);
|
||||
|
||||
let v2: &mut [i32] = &mut [0, 1, 2, 3, 4];
|
||||
let mut c2 = v2.chunks_mut(3);
|
||||
assert_eq!(c2.nth(1).unwrap()[1], 4);
|
||||
assert_eq!(c2.nth(1).unwrap(), &[3, 4]);
|
||||
assert_eq!(c2.next(), None);
|
||||
}
|
||||
|
||||
@ -181,11 +181,11 @@ fn test_chunks_mut_nth() {
|
||||
fn test_chunks_mut_last() {
|
||||
let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
|
||||
let c = v.chunks_mut(2);
|
||||
assert_eq!(c.last().unwrap()[1], 5);
|
||||
assert_eq!(c.last().unwrap(), &[4, 5]);
|
||||
|
||||
let v2: &mut [i32] = &mut [0, 1, 2, 3, 4];
|
||||
let c2 = v2.chunks_mut(2);
|
||||
assert_eq!(c2.last().unwrap()[0], 4);
|
||||
assert_eq!(c2.last().unwrap(), &[4]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user