Add a new VOC that includes SoundDataContinuation.

Add tests for it.
This commit is contained in:
Pedro de Oliveira 2023-04-30 05:34:19 +01:00
parent a67270e671
commit d5e3e5b817
2 changed files with 63 additions and 0 deletions

BIN
assets/C24FF78A.VOC Normal file

Binary file not shown.

63
tests/test_c24ff78a.rs Normal file
View File

@ -0,0 +1,63 @@
use vocnom::reader::parse_voc;
use vocnom::types::{BlockType, Codec};
const VOC_CONTENTS: &[u8] = include_bytes!("../assets/C24FF78A.VOC");
#[test]
fn version_test() {
let (_, voc) = parse_voc(VOC_CONTENTS).unwrap();
assert_eq!((voc.version.major, voc.version.minor), (1, 20));
}
#[test]
fn checksum_test() {
let (_, voc) = parse_voc(VOC_CONTENTS).unwrap();
assert!(voc.checksum.valid);
assert_eq!(voc.checksum.value, 0x111f);
}
#[test]
fn num_blocks_test() {
let (_, voc) = parse_voc(VOC_CONTENTS).unwrap();
assert_eq!(voc.blocks.len(), 458);
}
#[test]
fn block_0_sound_data_test() {
let (_, voc) = parse_voc(VOC_CONTENTS).unwrap();
if let BlockType::SoundData {
sample_rate,
codec,
data,
} = &voc.blocks[1]
{
assert_eq!(sample_rate, &11111);
assert_eq!(codec, &Codec::Pcm8BitUnsigned);
assert_eq!(data.len(), 485);
}
}
#[test]
fn blocks_1_to_457_terminator_test() {
let (_, voc) = parse_voc(VOC_CONTENTS).unwrap();
for idx in 1..457 {
assert!(matches!(
voc.blocks[idx],
BlockType::SoundDataContinuation { .. }
));
}
}
#[test]
fn block_69_sound_data_continuation() {
let (_, voc) = parse_voc(VOC_CONTENTS).unwrap();
if let BlockType::SoundDataContinuation { data } = &voc.blocks[1] {
assert_eq!(data.len(), 500);
}
}
#[test]
fn block_458_terminator_test() {
let (_, voc) = parse_voc(VOC_CONTENTS).unwrap();
assert_eq!(&voc.blocks[457], &BlockType::Terminator);
}