Add a new VOC that includes SoundDataContinuation.
Add tests for it.
This commit is contained in:
parent
a67270e671
commit
d5e3e5b817
Binary file not shown.
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue