1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#[macro_use] extern crate lazy_static; extern crate regex; extern crate xml; extern crate zip; use std::io::{Result, BufReader, Read, Seek}; mod summarize; mod common; pub fn process<R: Read + Seek>(reader: BufReader<R>) -> Result<common::Summary> { let zip_file = try!(zip::ZipArchive::new(reader)); let summary = try!(summarize::summarize(zip_file)); Ok(summary) } #[cfg(test)] mod tests { use super::process; use std::fs::File; use std::io::{BufReader}; fn get_zip_file() -> File { if let Ok(file) = File::open("test.imscc") { file } else { panic!("Could not find test file 'test.imscc'") } } #[test] #[ignore] fn test_process() { let file = get_zip_file(); match process(BufReader::new(file)) { Ok(summary) => { assert_eq!(summary.general.title, "Tommy's Awesome Course"); assert_eq!(summary.general.copyright, "Private (Copyrighted) - http://en.wikipedia.org/wiki/Copyright"); assert_eq!(summary.general.description, ""); assert_eq!(summary.modules.len(), 105); } Err(e) => { panic!(e) } } } }