From 5c90b1141533c5c83dc61eebdfa85a33fecd2985 Mon Sep 17 00:00:00 2001 From: AbeZbm <128758303@qq.com> Date: Thu, 15 May 2025 14:52:54 +0800 Subject: [PATCH] Add missing tests in test_bytes --- tests/test_bytes.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs index 613efc8..f36abaa 100644 --- a/tests/test_bytes.rs +++ b/tests/test_bytes.rs @@ -157,6 +157,13 @@ fn slice_oob_2() { a.slice(44..49); } +#[test] +#[should_panic] +fn slice_start_greater_than_end() { + let a = Bytes::from(&b"hello world"[..]); + a.slice(5..3); +} + #[test] fn split_off() { let mut hello = Bytes::from(&b"helloworld"[..]); @@ -724,6 +731,15 @@ fn advance_past_len() { a.advance(20); } +#[test] +#[should_panic] +fn mut_advance_past_len() { + let mut a = BytesMut::from("hello world"); + unsafe { + a.advance_mut(20); + } +} + #[test] // Only run these tests on little endian systems. CI uses qemu for testing // big endian... and qemu doesn't really support threading all that well.