diff --git a/src/tests.rs b/src/tests.rs index bc4f3f6..7643fd7 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -111,6 +111,13 @@ fn drain() { assert_eq!(v.drain(1..).collect::>(), &[4, 5]); // drain should not change the capacity assert_eq!(v.capacity(), old_capacity); + + // Exercise the tail-shifting code when in the inline state + // This has the potential to produce UB due to aliasing + let mut v: SmallVec<[u8; 2]> = SmallVec::new(); + v.push(1); + v.push(2); + assert_eq!(v.drain(..1).collect::>(), &[1]); } #[test]