summaryrefslogtreecommitdiffstats
path: root/third_party/rust/smallvec/src/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/smallvec/src/tests.rs')
-rw-r--r--third_party/rust/smallvec/src/tests.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/third_party/rust/smallvec/src/tests.rs b/third_party/rust/smallvec/src/tests.rs
index bb39ddeb31..3eab846bf2 100644
--- a/third_party/rust/smallvec/src/tests.rs
+++ b/third_party/rust/smallvec/src/tests.rs
@@ -72,13 +72,13 @@ pub fn test_double_spill() {
);
}
-/// https://github.com/servo/rust-smallvec/issues/4
+// https://github.com/servo/rust-smallvec/issues/4
#[test]
fn issue_4() {
SmallVec::<[Box<u32>; 2]>::new();
}
-/// https://github.com/servo/rust-smallvec/issues/5
+// https://github.com/servo/rust-smallvec/issues/5
#[test]
fn issue_5() {
assert!(Some(SmallVec::<[&u32; 2]>::new()).is_some());
@@ -833,12 +833,9 @@ fn test_write() {
}
#[cfg(feature = "serde")]
-extern crate bincode;
-
-#[cfg(feature = "serde")]
#[test]
fn test_serde() {
- use self::bincode::{config, deserialize};
+ use bincode::{config, deserialize};
let mut small_vec: SmallVec<[i32; 2]> = SmallVec::new();
small_vec.push(1);
let encoded = config().limit(100).serialize(&small_vec).unwrap();
@@ -925,6 +922,12 @@ fn const_new() {
assert_eq!(v.len(), 2);
assert_eq!(v[0], 1);
assert_eq!(v[1], 4);
+ let v = const_new_with_len();
+ assert_eq!(v.capacity(), 4);
+ assert_eq!(v.len(), 3);
+ assert_eq!(v[0], 2);
+ assert_eq!(v[1], 5);
+ assert_eq!(v[2], 7);
}
#[cfg(feature = "const_new")]
const fn const_new_inner() -> SmallVec<[i32; 4]> {
@@ -938,6 +941,12 @@ const fn const_new_inline_sized() -> SmallVec<[i32; 4]> {
const fn const_new_inline_args() -> SmallVec<[i32; 2]> {
crate::smallvec_inline![1, 4]
}
+#[cfg(feature = "const_new")]
+const fn const_new_with_len() -> SmallVec<[i32; 4]> {
+ unsafe {
+ SmallVec::<[i32; 4]>::from_const_with_len_unchecked([2, 5, 7, 0], 3)
+ }
+}
#[test]
fn empty_macro() {