diff --git a/video/closedcaption/src/mcc_parse/parser.rs b/video/closedcaption/src/mcc_parse/parser.rs index 7cf9c034..7391e8ca 100644 --- a/video/closedcaption/src/mcc_parse/parser.rs +++ b/video/closedcaption/src/mcc_parse/parser.rs @@ -388,59 +388,6 @@ impl MccParser { mod tests { use super::*; - #[test] - fn test_timecode() { - assert_eq!( - timecode(b"11:12:13;14".as_ref()), - Ok(( - b"".as_ref(), - TimeCode { - hours: 11, - minutes: 12, - seconds: 13, - frames: 14, - drop_frame: true - }, - )) - ); - - assert_eq!( - timecode(b"11:12:13:14".as_ref()), - Ok(( - b"".as_ref(), - TimeCode { - hours: 11, - minutes: 12, - seconds: 13, - frames: 14, - drop_frame: false - }, - )) - ); - - assert_eq!( - timecode(b"11:12:13:14abcd".as_ref()), - Ok(( - b"abcd".as_ref(), - TimeCode { - hours: 11, - minutes: 12, - seconds: 13, - frames: 14, - drop_frame: false - }, - )) - ); - - assert_eq!( - timecode(b"abcd11:12:13:14".as_ref()), - Err(nom::Err::Error(nom::error::Error::new( - b"abcd11:12:13:14".as_ref(), - nom::error::ErrorKind::MapRes - ))), - ); - } - #[test] fn test_header() { assert_eq!( diff --git a/video/closedcaption/src/parser_utils.rs b/video/closedcaption/src/parser_utils.rs index 63fe2faa..90bf1493 100644 --- a/video/closedcaption/src/parser_utils.rs +++ b/video/closedcaption/src/parser_utils.rs @@ -88,3 +88,61 @@ pub fn end_of_line(s: &[u8]) -> IResult<&[u8], ()> { map(pair(opt(alt((tag("\r\n"), tag("\n")))), eof), |_| ())(s) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_timecode() { + assert_eq!( + timecode(b"11:12:13;14".as_ref()), + Ok(( + b"".as_ref(), + TimeCode { + hours: 11, + minutes: 12, + seconds: 13, + frames: 14, + drop_frame: true + }, + )) + ); + + assert_eq!( + timecode(b"11:12:13:14".as_ref()), + Ok(( + b"".as_ref(), + TimeCode { + hours: 11, + minutes: 12, + seconds: 13, + frames: 14, + drop_frame: false + }, + )) + ); + + assert_eq!( + timecode(b"11:12:13:14abcd".as_ref()), + Ok(( + b"abcd".as_ref(), + TimeCode { + hours: 11, + minutes: 12, + seconds: 13, + frames: 14, + drop_frame: false + }, + )) + ); + + assert_eq!( + timecode(b"abcd11:12:13:14".as_ref()), + Err(nom::Err::Error(nom::error::Error::new( + b"abcd11:12:13:14".as_ref(), + nom::error::ErrorKind::MapRes + ))), + ); + } +} diff --git a/video/closedcaption/src/scc_parse/parser.rs b/video/closedcaption/src/scc_parse/parser.rs index 0a541669..b1b77cd7 100644 --- a/video/closedcaption/src/scc_parse/parser.rs +++ b/video/closedcaption/src/scc_parse/parser.rs @@ -184,59 +184,6 @@ impl SccParser { mod tests { use super::*; - #[test] - fn test_timecode() { - assert_eq!( - timecode(b"11:12:13;14".as_ref()), - Ok(( - b"".as_ref(), - TimeCode { - hours: 11, - minutes: 12, - seconds: 13, - frames: 14, - drop_frame: true - }, - )) - ); - - assert_eq!( - timecode(b"11:12:13:14".as_ref()), - Ok(( - b"".as_ref(), - TimeCode { - hours: 11, - minutes: 12, - seconds: 13, - frames: 14, - drop_frame: false - }, - )) - ); - - assert_eq!( - timecode(b"11:12:13:14abcd".as_ref()), - Ok(( - b"abcd".as_ref(), - TimeCode { - hours: 11, - minutes: 12, - seconds: 13, - frames: 14, - drop_frame: false - }, - )) - ); - - assert_eq!( - timecode(b"abcd11:12:13:14".as_ref()), - Err(nom::Err::Error(nom::error::Error::new( - b"abcd11:12:13:14".as_ref(), - nom::error::ErrorKind::MapRes - ))), - ); - } - #[test] fn test_header() { assert_eq!(