From ed774838b372bf532a3fb221601bdcd1c8856277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 11 Jan 2018 12:12:55 +0200 Subject: [PATCH] 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. --- src/libcore/tests/slice.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index d6230e93f998d..4f9fc30785c73 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -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]