convert bin/stub into a sanity test
This commit is contained in:
parent
da54623006
commit
f890437c17
4 changed files with 31 additions and 29 deletions
|
@ -1,28 +0,0 @@
|
||||||
extern crate webmetro;
|
|
||||||
|
|
||||||
use std::io::{Cursor, stdout, Write};
|
|
||||||
use webmetro::webm::*;
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let mut cursor = Cursor::new(Vec::new());
|
|
||||||
|
|
||||||
encode_webm_element(WebmElement::EbmlHead, &mut cursor).unwrap();
|
|
||||||
encode_webm_element(WebmElement::Segment, &mut cursor).unwrap();
|
|
||||||
|
|
||||||
encode_webm_element(WebmElement::Tracks(&[]), &mut cursor).unwrap();
|
|
||||||
|
|
||||||
encode_webm_element(WebmElement::Cluster, &mut cursor).unwrap();
|
|
||||||
encode_webm_element(WebmElement::Timecode(0), &mut cursor).unwrap();
|
|
||||||
|
|
||||||
encode_webm_element(WebmElement::SimpleBlock(SimpleBlock {
|
|
||||||
track: 3,
|
|
||||||
flags: 0x0,
|
|
||||||
timecode: 123,
|
|
||||||
data: "Hello, World".as_bytes()
|
|
||||||
}), &mut cursor).unwrap();
|
|
||||||
|
|
||||||
encode_webm_element(WebmElement::Cluster, &mut cursor).unwrap();
|
|
||||||
encode_webm_element(WebmElement::Timecode(1000), &mut cursor).unwrap();
|
|
||||||
|
|
||||||
stdout().write_all(&cursor.get_ref()).unwrap();
|
|
||||||
}
|
|
BIN
src/data/encode_webm_test.webm
Normal file
BIN
src/data/encode_webm_test.webm
Normal file
Binary file not shown.
|
@ -21,6 +21,7 @@ mod tests {
|
||||||
use futures::future::{ok, Future};
|
use futures::future::{ok, Future};
|
||||||
|
|
||||||
pub const TEST_FILE: &'static [u8] = include_bytes!("data/test1.webm");
|
pub const TEST_FILE: &'static [u8] = include_bytes!("data/test1.webm");
|
||||||
|
pub const ENCODE_WEBM_TEST_FILE: &'static [u8] = include_bytes!("data/encode_webm_test.webm");
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hello_futures() {
|
fn hello_futures() {
|
||||||
|
|
31
src/webm.rs
31
src/webm.rs
|
@ -131,7 +131,10 @@ pub fn encode_webm_element<T: Write + Seek>(element: WebmElement, output: &mut T
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use tests::TEST_FILE;
|
use tests::{
|
||||||
|
TEST_FILE,
|
||||||
|
ENCODE_WEBM_TEST_FILE
|
||||||
|
};
|
||||||
use webm::*;
|
use webm::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -188,4 +191,30 @@ mod tests {
|
||||||
assert_eq!(iter.next(), Some(WebmElement::Cues));
|
assert_eq!(iter.next(), Some(WebmElement::Cues));
|
||||||
assert_eq!(iter.next(), None);
|
assert_eq!(iter.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn encode_webm_test() {
|
||||||
|
let mut cursor = Cursor::new(Vec::new());
|
||||||
|
|
||||||
|
encode_webm_element(WebmElement::EbmlHead, &mut cursor).unwrap();
|
||||||
|
encode_webm_element(WebmElement::Segment, &mut cursor).unwrap();
|
||||||
|
|
||||||
|
encode_webm_element(WebmElement::Tracks(&[]), &mut cursor).unwrap();
|
||||||
|
|
||||||
|
encode_webm_element(WebmElement::Cluster, &mut cursor).unwrap();
|
||||||
|
encode_webm_element(WebmElement::Timecode(0), &mut cursor).unwrap();
|
||||||
|
|
||||||
|
encode_webm_element(WebmElement::SimpleBlock(SimpleBlock {
|
||||||
|
track: 3,
|
||||||
|
flags: 0x0,
|
||||||
|
timecode: 123,
|
||||||
|
data: "Hello, World".as_bytes()
|
||||||
|
}), &mut cursor).unwrap();
|
||||||
|
|
||||||
|
encode_webm_element(WebmElement::Cluster, &mut cursor).unwrap();
|
||||||
|
encode_webm_element(WebmElement::Timecode(1000), &mut cursor).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(cursor.get_ref(), &ENCODE_WEBM_TEST_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue