diff --git a/crates/audio-io/tests/stream.rs b/crates/audio-io/tests/stream.rs index 61a28946..7b149ca6 100644 --- a/crates/audio-io/tests/stream.rs +++ b/crates/audio-io/tests/stream.rs @@ -52,13 +52,15 @@ fn streamed_files_match_whole_buffer_encodes() { #[test] fn blocks_past_a_format_limit_are_refused_before_anything_is_written() { let buf = tone(2, 100); - for (format, limit) in [(FileFormat::Aiff, 1usize << 30), (FileFormat::Flac, 1 << 36)] { + for (format, limit) in [(FileFormat::Aiff, 1u64 << 30), (FileFormat::Flac, 1u64 << 36)] { let opts = EncodeOptions { format, bit_depth: BitDepth::Int16, dither: false, bwf: None }; let mut enc = FileEncoder::new(Cursor::new(Vec::new()), &opts, 2, buf.sample_rate, None).unwrap(); enc.write(&buf.channels, 100).unwrap(); - assert!(enc.check_room(limit as u64 / 2).is_ok(), "{format:?}"); - assert!(matches!(enc.check_room(limit as u64), Err(AudioError::TooLarge(_))), "{format:?}"); - assert!(matches!(enc.write(&[], limit), Err(AudioError::TooLarge(_))), "{format:?}"); + assert!(enc.check_room(limit / 2).is_ok(), "{format:?}"); + assert!(matches!(enc.check_room(limit), Err(AudioError::TooLarge(_))), "{format:?}"); + if let Ok(frames) = usize::try_from(limit) { + assert!(matches!(enc.write(&[], frames), Err(AudioError::TooLarge(_))), "{format:?}"); + } assert_eq!(enc.finish().unwrap().into_inner(), encode(&buf, &opts).unwrap()); } }