-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b03e011
commit 6f3e793
Showing
5 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod ops; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
extern crate image; | ||
extern crate termimage; | ||
|
||
use std::path::PathBuf; | ||
use self::image::ImageFormat; | ||
use self::termimage::Outcome; | ||
use self::termimage::ops::guess_format; | ||
|
||
|
||
#[test] | ||
fn png() { | ||
test_correct("png", ImageFormat::PNG); | ||
} | ||
|
||
#[test] | ||
fn jpeg() { | ||
test_correct("jpg", ImageFormat::JPEG); | ||
test_correct("jpeg", ImageFormat::JPEG); | ||
test_correct("jpe", ImageFormat::JPEG); | ||
test_correct("jif", ImageFormat::JPEG); | ||
test_correct("jfif", ImageFormat::JPEG); | ||
test_correct("jfi", ImageFormat::JPEG); | ||
} | ||
|
||
#[test] | ||
fn gif() { | ||
test_correct("gif", ImageFormat::GIF); | ||
} | ||
|
||
#[test] | ||
fn webp() { | ||
test_correct("webp", ImageFormat::WEBP); | ||
} | ||
|
||
#[test] | ||
fn ppm() { | ||
test_correct("ppm", ImageFormat::PPM); | ||
} | ||
|
||
#[test] | ||
fn tiff() { | ||
test_correct("tiff", ImageFormat::TIFF); | ||
test_correct("tif", ImageFormat::TIFF); | ||
} | ||
|
||
#[test] | ||
fn tga() { | ||
test_correct("tga", ImageFormat::TGA); | ||
} | ||
|
||
#[test] | ||
fn bmp() { | ||
test_correct("bmp", ImageFormat::BMP); | ||
test_correct("dib", ImageFormat::BMP); | ||
} | ||
|
||
#[test] | ||
fn ico() { | ||
test_correct("ico", ImageFormat::ICO); | ||
} | ||
|
||
#[test] | ||
fn hdr() { | ||
test_correct("hdr", ImageFormat::HDR); | ||
} | ||
|
||
#[test] | ||
fn unknown() { | ||
let p = "../tests/ops/guess_format.rs".to_string(); | ||
assert_eq!(guess_format(&(p.clone(), PathBuf::from(&p))), Err(Outcome::GuessingFormatFailed(p))); | ||
} | ||
|
||
|
||
fn test_correct(ext: &str, f: ImageFormat) { | ||
assert_eq!(guess_format(&(String::new(), PathBuf::from(format!("img.{}", ext)))), Ok(f)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod guess_format; |