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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#![deny(missing_docs)]
mod decoder;
mod error;
pub mod types;
pub use error::Error;
pub use decoder::BmpDecoder;
pub type Result<T> = std::result::Result<T, error::Error>;
#[cfg(test)]
mod tests {
use super::*;
use tokio::{
fs::File,
stream::StreamExt,
};
use tokio_util::codec::FramedRead;
use std::ffi::OsStr;
use std::fs;
#[tokio::test]
async fn test_data() {
for entry in fs::read_dir("test_data/").unwrap() {
let entry = entry.unwrap();
match entry.path().extension() {
Some(ext) if ext == OsStr::new("dump") => {
println!("Testing {}", entry.path().display());
let fh = File::open(&entry.path()).await.unwrap();
let mut rdr = FramedRead::new(fh, BmpDecoder::new());
while let Some(msg) = rdr.next().await {
match msg {
Ok(_) => {},
Err(err) => panic!("Error: {}", err)
};
}
},
_ => {}
};
}
}
}