Replace panic! with assert

This commit is contained in:
Pedro de Oliveira 2023-04-23 01:37:59 +01:00
parent 189afa26ba
commit 295631802d
1 changed files with 15 additions and 15 deletions

View File

@ -26,25 +26,25 @@ impl VocFile {
// Signature - Creative Voice File
let mut signature1_buffer: [u8; 19] = [0; 19];
file.read_exact(&mut signature1_buffer).unwrap();
let signature1 = std::str::from_utf8(&signature1_buffer).unwrap();
if signature1 != Self::SIGNATURE1 {
panic!(
"Bad file. Expected \"{}\" got \"{}\"",
Self::SIGNATURE1,
signature1
);
}
let signature1_str = std::str::from_utf8(&signature1_buffer).unwrap();
assert_eq!(
signature1_str,
Self::SIGNATURE1,
"Bad file. Expected \"{}\" got \"{}\"",
Self::SIGNATURE1,
signature1_str
);
// Signature - 1A 1A 00
let mut signature2_buffer: [u8; 3] = [0; 3];
file.read_exact(&mut signature2_buffer).unwrap();
if signature2_buffer != Self::SIGNATURE2 {
panic!(
"Bad file. Expected {:02X?} got {:02X?}",
Self::SIGNATURE2,
signature2_buffer
);
}
assert_eq!(
signature2_buffer,
Self::SIGNATURE2,
"Bad file. Expected {:02X?} got {:02X?}",
Self::SIGNATURE2,
signature2_buffer
);
// Version
let mut version_buffer: [u8; 2] = [0; 2];