From 539b170f7ec4ca37b904876c5cf70bf016477bd6 Mon Sep 17 00:00:00 2001 From: Matthew Jackson <1085847+MattJackson@users.noreply.github.com> Date: Thu, 25 Jun 2026 21:42:52 -0700 Subject: [PATCH] test(disc): pin the -t 1 = main-feature contract (DVD); fix 2 test clippy nits Owner-flagged invariant: freemkv -t 1 ALWAYS selects the main feature because the CLI's title 1 maps to titles[0] and the list is ordered by canonical_title_order (main feature first). Adds a DVD-shaped contract pin asserting titles[0] is the movie after sorting (a regression there is a title-ordering bug, not a remux issue), complementing the existing branching-UHD / normal-disc order tests. Also clears two pre-existing test-only clippy nits surfaced under --all-targets: unused `lba` in ClearStubReader::read_sectors, and an unneeded `mut` on the h264 population test's closure. --- src/disc/mod.rs | 23 ++++++++++++++++++++++- src/mux/codec/h264.rs | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/disc/mod.rs b/src/disc/mod.rs index 1ae2c64..325d9e5 100644 --- a/src/disc/mod.rs +++ b/src/disc/mod.rs @@ -3880,6 +3880,27 @@ mod tests { assert_eq!(titles[2].playlist, "00100.mpls"); } + /// Contract pin (owner-flagged): `freemkv -t 1` ALWAYS selects the main + /// feature. The CLI's `-t 1` maps to `titles[0]`, and the title list is + /// ordered by `canonical_title_order` (main feature first), so `titles[0]` + /// IS the movie. Anything but the main feature at index 0 is a + /// title-ordering bug, not a remux problem. DVD-shaped fixture (DVD-9 + /// capacity; a 1h49m main feature alongside a menu loop and a short extra). + #[test] + fn title_index_0_is_main_feature_dvd_the_dash_t_1_contract() { + const DVD9: u64 = 7_900_000_000; // dual-layer DVD + let mut titles = vec![ + title_with("VTS_01_menu", 120.0, 200_000_000, 1), // 2m menu/setup loop + title_with("VTS_02_main", 6540.0, 6_300_000_000, 1), // 1h49m main feature + title_with("VTS_03_extra", 900.0, 800_000_000, 1), // 15m extra + ]; + titles.sort_by(|a, b| Disc::canonical_title_order(a, b, DVD9)); + assert_eq!( + titles[0].playlist, "VTS_02_main", + "titles[0] (== what `freemkv -t 1` selects) must be the DVD main feature" + ); + } + /// Tiebreak: equal duration + equal capacity-validity → fewer /// clips wins. A chapter-stitched 3-clip movie should beat a /// 50-clip virtual composite of the same duration. @@ -4334,7 +4355,7 @@ mod tests { impl crate::sector::SectorSource for ClearStubReader { fn read_sectors( &mut self, - lba: u32, + _lba: u32, count: u16, buf: &mut [u8], _recovery: bool, diff --git a/src/mux/codec/h264.rs b/src/mux/codec/h264.rs index 603a7a5..5b5bed2 100644 --- a/src/mux/codec/h264.rs +++ b/src/mux/codec/h264.rs @@ -617,7 +617,7 @@ mod tests { // 0x98 = '1 00110..' → slice_type 5 (P) // 0x9C = '1 00111..' → slice_type 6 (B) let src = crate::pes::SourcePos::at_byte(8192); - let mut parse = |nal_type: u8, body: u8| { + let parse = |nal_type: u8, body: u8| { let mut p = H264Parser::new(); let mut pe = make_pes(h264_nal(nal_type, &[body]), Some(0)); pe.source = Some(src);