Skip to content

Commit ed77483

Browse files
committed
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.
1 parent baa81dc commit ed77483

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/libcore/tests/slice.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ fn test_chunks_count() {
117117
fn test_chunks_nth() {
118118
let v: &[i32] = &[0, 1, 2, 3, 4, 5];
119119
let mut c = v.chunks(2);
120-
assert_eq!(c.nth(1).unwrap()[1], 3);
121-
assert_eq!(c.next().unwrap()[0], 4);
120+
assert_eq!(c.nth(1).unwrap(), &[2, 3]);
121+
assert_eq!(c.next().unwrap(), &[4, 5]);
122122

123123
let v2: &[i32] = &[0, 1, 2, 3, 4];
124124
let mut c2 = v2.chunks(3);
125-
assert_eq!(c2.nth(1).unwrap()[1], 4);
125+
assert_eq!(c2.nth(1).unwrap(), &[3, 4]);
126126
assert_eq!(c2.next(), None);
127127
}
128128

@@ -168,24 +168,24 @@ fn test_chunks_mut_count() {
168168
fn test_chunks_mut_nth() {
169169
let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
170170
let mut c = v.chunks_mut(2);
171-
assert_eq!(c.nth(1).unwrap()[1], 3);
172-
assert_eq!(c.next().unwrap()[0], 4);
171+
assert_eq!(c.nth(1).unwrap(), &[2, 3]);
172+
assert_eq!(c.next().unwrap(), &[4, 5]);
173173

174174
let v2: &mut [i32] = &mut [0, 1, 2, 3, 4];
175175
let mut c2 = v2.chunks_mut(3);
176-
assert_eq!(c2.nth(1).unwrap()[1], 4);
176+
assert_eq!(c2.nth(1).unwrap(), &[3, 4]);
177177
assert_eq!(c2.next(), None);
178178
}
179179

180180
#[test]
181181
fn test_chunks_mut_last() {
182182
let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5];
183183
let c = v.chunks_mut(2);
184-
assert_eq!(c.last().unwrap()[1], 5);
184+
assert_eq!(c.last().unwrap(), &[4, 5]);
185185

186186
let v2: &mut [i32] = &mut [0, 1, 2, 3, 4];
187187
let c2 = v2.chunks_mut(2);
188-
assert_eq!(c2.last().unwrap()[0], 4);
188+
assert_eq!(c2.last().unwrap(), &[4]);
189189
}
190190

191191
#[test]

0 commit comments

Comments
 (0)