diff options
| author | Charles Lew <crlf0710@gmail.com> | 2020-01-12 18:01:24 +0800 |
|---|---|---|
| committer | Charles Lew <crlf0710@gmail.com> | 2020-01-12 18:34:35 +0800 |
| commit | d2c509a3c6b06ba02807bf94c00fad4c4a9262a5 (patch) | |
| tree | 59288e3a32b45eb3f1bff8332cf41cd03a36edb3 /src/liballoc/collections/linked_list | |
| parent | 091ba6daa0a0a528b5d9fc816529a9bb25503960 (diff) | |
| download | rust-d2c509a3c6b06ba02807bf94c00fad4c4a9262a5.tar.gz rust-d2c509a3c6b06ba02807bf94c00fad4c4a9262a5.zip | |
Address review comments.
Diffstat (limited to 'src/liballoc/collections/linked_list')
| -rw-r--r-- | src/liballoc/collections/linked_list/tests.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/liballoc/collections/linked_list/tests.rs b/src/liballoc/collections/linked_list/tests.rs index 29eb1b4abd7..d223752c7f7 100644 --- a/src/liballoc/collections/linked_list/tests.rs +++ b/src/liballoc/collections/linked_list/tests.rs @@ -313,15 +313,18 @@ fn test_cursor_move_peek() { assert_eq!(cursor.current(), Some(&1)); assert_eq!(cursor.peek_next(), Some(&2)); assert_eq!(cursor.peek_prev(), None); + assert_eq!(cursor.index(), Some(0)); cursor.move_prev(); assert_eq!(cursor.current(), None); assert_eq!(cursor.peek_next(), Some(&1)); assert_eq!(cursor.peek_prev(), Some(&6)); + assert_eq!(cursor.index(), None); cursor.move_next(); cursor.move_next(); assert_eq!(cursor.current(), Some(&2)); assert_eq!(cursor.peek_next(), Some(&3)); assert_eq!(cursor.peek_prev(), Some(&1)); + assert_eq!(cursor.index(), Some(1)); let mut m: LinkedList<u32> = LinkedList::new(); m.extend(&[1, 2, 3, 4, 5, 6]); @@ -329,20 +332,26 @@ fn test_cursor_move_peek() { assert_eq!(cursor.current(), Some(&mut 1)); assert_eq!(cursor.peek_next(), Some(&mut 2)); assert_eq!(cursor.peek_prev(), None); + assert_eq!(cursor.index(), Some(0)); cursor.move_prev(); assert_eq!(cursor.current(), None); assert_eq!(cursor.peek_next(), Some(&mut 1)); assert_eq!(cursor.peek_prev(), Some(&mut 6)); + assert_eq!(cursor.index(), None); cursor.move_next(); cursor.move_next(); assert_eq!(cursor.current(), Some(&mut 2)); assert_eq!(cursor.peek_next(), Some(&mut 3)); assert_eq!(cursor.peek_prev(), Some(&mut 1)); + assert_eq!(cursor.index(), Some(1)); let mut cursor2 = cursor.as_cursor(); assert_eq!(cursor2.current(), Some(&2)); + assert_eq!(cursor2.index(), Some(1)); cursor2.move_next(); assert_eq!(cursor2.current(), Some(&3)); + assert_eq!(cursor2.index(), Some(2)); assert_eq!(cursor.current(), Some(&mut 2)); + assert_eq!(cursor.index(), Some(1)); } #[test] |
