Add missing tests in test_bytes

This commit is contained in:
AbeZbm
2025-05-15 14:52:54 +08:00
parent 141cbc22cb
commit 5c90b11415
+16
View File
@@ -157,6 +157,13 @@ fn slice_oob_2() {
a.slice(44..49); 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] #[test]
fn split_off() { fn split_off() {
let mut hello = Bytes::from(&b"helloworld"[..]); let mut hello = Bytes::from(&b"helloworld"[..]);
@@ -724,6 +731,15 @@ fn advance_past_len() {
a.advance(20); a.advance(20);
} }
#[test]
#[should_panic]
fn mut_advance_past_len() {
let mut a = BytesMut::from("hello world");
unsafe {
a.advance_mut(20);
}
}
#[test] #[test]
// Only run these tests on little endian systems. CI uses qemu for testing // 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. // big endian... and qemu doesn't really support threading all that well.