forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

ir.rs24 lines, 960 bytesHistoryRawDownload
1#![no_main]
2
3use ec_subs::{SourceFormat, plain_text, srt, webvtt};
4use libfuzzer_sys::fuzz_target;
5
6// The IR the two parsers produce, and the conversion a caller makes out of it: plain text per cue,
7// style lookup by name, and the invariants a timeline depends on (no cue ends before it starts,
8// every skipped block is counted, the source format is the one parsed).
9fuzz_target!(|data: &[u8]| {
10 let text = String::from_utf8_lossy(data);
11 for bytes in [data, text.as_bytes()] {
12 if let Ok(track) = srt::parse(bytes) {
13 assert_eq!(track.source, Some(SourceFormat::Srt));
14 let _: String = track.cues.iter().map(|c| plain_text(&c.segments)).collect();
15 }
16 }
17 if let Ok(track) = webvtt::parse(data) {
18 assert_eq!(track.source, Some(SourceFormat::WebVtt));
19 for cue in &track.cues {
20 assert!(cue.end_us >= cue.start_us);
21 let _ = plain_text(&cue.segments);
22 }
23 }
24});