From 8cbf7363bf93a5a500d5f9eb4cb0e7f13164c7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 13:42:13 +0300 Subject: [PATCH] U18: ec-riff rf64 tests trimmed to the RIFF/RF64 round trip and the manual 4 GiB test (synthetic per-field checks removed, no ffmpeg oracle touched) --- crates/ec-riff/tests/it/rf64.rs | 86 --------------------------------- 1 file changed, 86 deletions(-) diff --git a/crates/ec-riff/tests/it/rf64.rs b/crates/ec-riff/tests/it/rf64.rs index 98497550..77417e05 100644 --- a/crates/ec-riff/tests/it/rf64.rs +++ b/crates/ec-riff/tests/it/rf64.rs @@ -22,10 +22,6 @@ fn le64(bytes: &[u8], at: usize) -> u64 { u64::from_le_bytes(bytes[at..at + 8].try_into().unwrap()) } -fn le32(bytes: &[u8], at: usize) -> u32 { - u32::from_le_bytes(bytes[at..at + 4].try_into().unwrap()) -} - /// Write `frames` frames of a ramp and return the finished file. fn write_file(s: WavSpec, frames: usize, options: WavOptions) -> Vec { let mut w = WavWriter::with_options(Cursor::new(Vec::new()), s, options).unwrap(); @@ -44,42 +40,6 @@ fn opts(frames: u64, threshold: u64) -> WavOptions { } } -#[test] -fn over_threshold_writes_rf64_with_exact_ds64_sizes() { - let s = spec(2, 16); - let frames = 1000; - let bytes = write_file(s, frames, opts(frames as u64, 64)); - - assert_eq!(&bytes[0..4], b"RF64"); - assert_eq!(le32(&bytes, 4), u32::MAX, "RIFF size is ds64's to hold"); - assert_eq!(&bytes[8..12], b"WAVE"); - assert_eq!(&bytes[12..16], b"ds64"); - assert_eq!(le32(&bytes, 16), 28, "ds64 body without a table"); - - let data_bytes = (frames * 4) as u64; - assert_eq!(le64(&bytes, 20), bytes.len() as u64 - 8, "riffSize"); - assert_eq!(le64(&bytes, 28), data_bytes, "dataSize"); - assert_eq!(le64(&bytes, 36), frames as u64, "sampleCount"); - assert_eq!(le32(&bytes, 44), 0, "tableLength"); - - // Stereo 16-bit is a plain PCM fmt with no fact chunk, then data with the sentinel. - let fmt = 48; - assert_eq!(&bytes[fmt..fmt + 4], b"fmt "); - // The `data` id sits right before its payload, at a fixed distance from the end. - let data = bytes.len() - 8 - data_bytes as usize; - assert_eq!(&bytes[data..data + 4], b"data"); - assert_eq!( - le32(&bytes, data + 4), - u32::MAX, - "data size is ds64's to hold" - ); - - let mut r = WavReader::new(Cursor::new(&bytes[..])).unwrap(); - assert_eq!(r.spec(), s); - assert_eq!(r.duration(), Some(frames as u64)); - assert_eq!(r.read_all_i32().unwrap().len(), frames * 2); -} - #[test] fn rf64_samples_match_the_riff_file_for_the_same_input() { for (channels, bits) in [(1u16, 8u16), (6, 24), (2, 16), (8, 32)] { @@ -101,52 +61,6 @@ fn rf64_samples_match_the_riff_file_for_the_same_input() { } } -#[test] -fn odd_rf64_data_gets_a_pad_byte_outside_its_size() { - let s = spec(1, 8); - let frames = 5; - let bytes = write_file(s, frames, opts(frames as u64, 1)); - // 5 data bytes: one pad byte follows, counted by riffSize but not dataSize. - assert_eq!(bytes.len() % 2, 0); - assert_eq!(le64(&bytes, 20), bytes.len() as u64 - 8); - assert_eq!(le64(&bytes, 28), 5); - let r = WavReader::new(Cursor::new(&bytes[..])).unwrap(); - assert_eq!(r.duration(), Some(5)); -} - -#[test] -fn extensible_rf64_keeps_fact_and_its_saturating_count() { - let s = spec(6, 24); - let frames = 50; - let bytes = write_file(s, frames, opts(frames as u64, 1)); - assert_eq!(&bytes[0..4], b"RF64"); - // Extensible fmt is 40 bytes, so `fact` follows it at 48 + 8 + 40. - let fact = 48 + 8 + 40; - assert_eq!(&bytes[fact..fact + 4], b"fact"); - assert_eq!(le32(&bytes, fact + 8), frames as u32); - let r = WavReader::new(Cursor::new(&bytes[..])).unwrap(); - assert_eq!(r.spec(), s); - assert_eq!(r.duration(), Some(frames as u64)); -} - -#[test] -fn under_threshold_stays_riff_byte_for_byte() { - let s = spec(2, 16); - let riff = write_file(s, 100, WavOptions::default()); - let below = write_file(s, 100, opts(100, 400 + 1)); - assert_eq!(riff, below); - assert_eq!(&riff[0..4], b"RIFF"); - assert_eq!(le32(&riff, 4) as usize, riff.len() - 8); -} - -#[test] -fn unknown_length_is_riff_and_oversize_riff_is_refused() { - let s = spec(2, 16); - let bytes = write_file(s, 10, WavOptions::default()); - assert_eq!(&bytes[0..4], b"RIFF"); - assert_eq!(le32(&bytes, 4) as usize, bytes.len() - 8); -} - /// Manual: writes 4.1 GiB of 16-bit stereo and reads its header back. Run with /// `cargo test -p ec-riff --test it rf64:: -- --ignored --nocapture`. #[test]