From feae5a08a2d5d8db14a4b99a050dbc14a6bffb2a Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Mon, 24 Apr 2017 09:49:29 -0500 Subject: [PATCH] Add Splice forget test --- src/libcollections/tests/string.rs | 7 +++++++ src/libcollections/tests/vec.rs | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/libcollections/tests/string.rs b/src/libcollections/tests/string.rs index a32f5e3357f38..b1731b2a5dcaa 100644 --- a/src/libcollections/tests/string.rs +++ b/src/libcollections/tests/string.rs @@ -475,6 +475,13 @@ fn test_splice_unbounded() { assert_eq!(t, "12345"); } +#[test] +fn test_splice_forget() { + let mut s = String::from("12345"); + ::std::mem::forget(s.splice(2..4, "789")); + assert_eq!(s, "12345"); +} + #[test] fn test_extend_ref() { let mut a = "foo".to_string(); diff --git a/src/libcollections/tests/vec.rs b/src/libcollections/tests/vec.rs index f47940dc33aa1..29f18274962fe 100644 --- a/src/libcollections/tests/vec.rs +++ b/src/libcollections/tests/vec.rs @@ -634,6 +634,14 @@ fn test_splice_unbounded() { assert_eq!(t, &[1, 2, 3, 4, 5]); } +#[test] +fn test_splice_forget() { + let mut v = vec![1, 2, 3, 4, 5]; + let a = [10, 11, 12]; + ::std::mem::forget(v.splice(2..4, a.iter().cloned())); + assert_eq!(v, &[1, 2]); +} + #[test] fn test_into_boxed_slice() { let xs = vec![1, 2, 3];