closedcaption: Move duplicated test into a single place

This commit is contained in:
Sebastian Dröge 2020-11-06 12:30:44 +02:00
parent 82c8a7b7e8
commit cbe54c0827
3 changed files with 58 additions and 106 deletions

View file

@ -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!(

View file

@ -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
))),
);
}
}

View file

@ -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!(