From 46c70e8a27f7825c73b561fbd09c60b0c050ea5e Mon Sep 17 00:00:00 2001 From: prakrititz Date: Mon, 31 Aug 2026 09:11:17 +0530 Subject: [PATCH 1/2] test: add deterministic expected panic substrings to #[should_panic] tests --- tests/bytes.rs | 6 +++--- tests/main.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/bytes.rs b/tests/bytes.rs index 71dbdd5..2698e59 100644 --- a/tests/bytes.rs +++ b/tests/bytes.rs @@ -60,7 +60,7 @@ fn test_put_int() { } #[test] -#[should_panic] +#[should_panic(expected = "cannot write")] fn test_put_int_nbytes_overflow() { let mut buf = SmallVec::with_capacity(8); buf.put_int(0x1020304050607080, 9); @@ -74,14 +74,14 @@ fn test_put_int_le() { } #[test] -#[should_panic] +#[should_panic(expected = "cannot write")] fn test_put_int_le_nbytes_overflow() { let mut buf = SmallVec::with_capacity(8); buf.put_int_le(0x1020304050607080, 9); } #[test] -#[should_panic(expected = "advance out of bounds: the len is 8 but advancing by 12")] +#[should_panic(expected = "advance out of bounds")] fn test_smallvec_advance_mut() { let mut buf = SmallVec::with_capacity(8); unsafe { diff --git a/tests/main.rs b/tests/main.rs index a1a0508..2ddd837 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -386,7 +386,7 @@ fn test_append() { } #[test] -#[should_panic] +#[should_panic(expected = "new_capacity >= len")] fn test_invalid_grow() { let mut v: SmallVec = SmallVec::new(); v.extend(0..8); @@ -394,7 +394,7 @@ fn test_invalid_grow() { } #[test] -#[should_panic] +#[should_panic(expected = "attempted to index slice up to maximum usize")] fn drain_overflow() { let mut v: SmallVec = smallvec![0]; v.drain(..=usize::MAX); @@ -425,7 +425,7 @@ fn test_extend_from_within() { } #[test] -#[should_panic] +#[should_panic(expected = "drop")] fn test_drop_panic_smallvec() { // This test should only panic once, and not double panic, // which would mean a double drop @@ -963,21 +963,21 @@ fn max_dont_panic() { } #[test] -#[should_panic] +#[should_panic(expected = "removal index")] fn max_remove() { let mut sv: SmallVec = smallvec![0]; sv.remove(usize::MAX); } #[test] -#[should_panic] +#[should_panic(expected = "swap_remove index")] fn max_swap_remove() { let mut sv: SmallVec = smallvec![0]; sv.swap_remove(usize::MAX); } #[test] -#[should_panic] +#[should_panic(expected = "insertion index")] fn max_insert() { let mut sv: SmallVec = smallvec![0]; sv.insert(usize::MAX, 0); From 6d8b6193fb9939c94345a43ddf5860030992f300 Mon Sep 17 00:00:00 2001 From: prakrititz Date: Mon, 31 Aug 2026 19:55:40 +0530 Subject: [PATCH 2/2] feat: updated #[should_panic] attributes for failed testcases #502 updated the panic attributes for the following failures: test_put_int_le_nbytes_overflow test_put_int_nbytes_overflow --- tests/bytes.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bytes.rs b/tests/bytes.rs index 2698e59..2f6d334 100644 --- a/tests/bytes.rs +++ b/tests/bytes.rs @@ -60,7 +60,7 @@ fn test_put_int() { } #[test] -#[should_panic(expected = "cannot write")] +#[should_panic(expected = "size too large")] fn test_put_int_nbytes_overflow() { let mut buf = SmallVec::with_capacity(8); buf.put_int(0x1020304050607080, 9); @@ -74,7 +74,7 @@ fn test_put_int_le() { } #[test] -#[should_panic(expected = "cannot write")] +#[should_panic(expected = "size too large")] fn test_put_int_le_nbytes_overflow() { let mut buf = SmallVec::with_capacity(8); buf.put_int_le(0x1020304050607080, 9);