Skip to content

Commit 2278b33

Browse files
committed
ArrayVecCopy: Add test that it is copy
1 parent 6f39b07 commit 2278b33

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/tests.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ extern crate arrayvec;
33

44
use arrayvec::ArrayVec;
55
use arrayvec::ArrayString;
6+
use arrayvec::ArrayVecCopy;
67
use std::mem;
78
use arrayvec::CapacityError;
89

@@ -774,3 +775,23 @@ fn test_arraystring_zero_filled_has_some_sanity_checks() {
774775
assert_eq!(string.as_str(), "\0\0\0\0");
775776
assert_eq!(string.len(), 4);
776777
}
778+
779+
#[test]
780+
fn test_arrayvec_copy_is_copy() {
781+
let mut vec: ArrayVecCopy<usize, 10> = ArrayVecCopy::new();
782+
783+
vec.try_extend_from_slice(&[1, 2, 3]).unwrap();
784+
assert_eq!(vec.len(), 3);
785+
assert_eq!(&vec[..], &[1, 2, 3]);
786+
787+
let copy = vec;
788+
789+
assert_eq!(&copy[..], &vec[..]);
790+
791+
let many_duplicates = [copy; 16];
792+
793+
// deref to copy in pattern
794+
for &dup in &many_duplicates {
795+
assert_eq!(dup, vec);
796+
}
797+
}

0 commit comments

Comments
 (0)