summaryrefslogtreecommitdiffstats
path: root/library/alloc/tests/vec.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /library/alloc/tests/vec.rs
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/alloc/tests/vec.rs')
-rw-r--r--library/alloc/tests/vec.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs
index 2f07c2911..3ee16f04e 100644
--- a/library/alloc/tests/vec.rs
+++ b/library/alloc/tests/vec.rs
@@ -1,5 +1,7 @@
use core::alloc::{Allocator, Layout};
+use core::assert_eq;
use core::iter::IntoIterator;
+use core::num::NonZeroUsize;
use core::ptr::NonNull;
use std::alloc::System;
use std::assert_matches::assert_matches;
@@ -1062,21 +1064,21 @@ fn test_into_iter_leak() {
#[test]
fn test_into_iter_advance_by() {
- let mut i = [1, 2, 3, 4, 5].into_iter();
- i.advance_by(0).unwrap();
- i.advance_back_by(0).unwrap();
+ let mut i = vec![1, 2, 3, 4, 5].into_iter();
+ assert_eq!(i.advance_by(0), Ok(()));
+ assert_eq!(i.advance_back_by(0), Ok(()));
assert_eq!(i.as_slice(), [1, 2, 3, 4, 5]);
- i.advance_by(1).unwrap();
- i.advance_back_by(1).unwrap();
+ assert_eq!(i.advance_by(1), Ok(()));
+ assert_eq!(i.advance_back_by(1), Ok(()));
assert_eq!(i.as_slice(), [2, 3, 4]);
- assert_eq!(i.advance_back_by(usize::MAX), Err(3));
+ assert_eq!(i.advance_back_by(usize::MAX), Err(NonZeroUsize::new(usize::MAX - 3).unwrap()));
- assert_eq!(i.advance_by(usize::MAX), Err(0));
+ assert_eq!(i.advance_by(usize::MAX), Err(NonZeroUsize::new(usize::MAX).unwrap()));
- i.advance_by(0).unwrap();
- i.advance_back_by(0).unwrap();
+ assert_eq!(i.advance_by(0), Ok(()));
+ assert_eq!(i.advance_back_by(0), Ok(()));
assert_eq!(i.len(), 0);
}
@@ -1124,7 +1126,7 @@ fn test_into_iter_zst() {
for _ in vec![C; 5].into_iter().rev() {}
let mut it = vec![C, C].into_iter();
- it.advance_by(1).unwrap();
+ assert_eq!(it.advance_by(1), Ok(()));
drop(it);
let mut it = vec![C, C].into_iter();