Format code using 'cargo fmt'
This commit is contained in:
10 files changed
+488
-292
No files matched your search
+30
-33
@@ -1,12 +1,12 @@
|
||||
extern crate tiff;
|
||||
extern crate tempfile;
|
||||
extern crate tiff;
|
||||
|
||||
use tiff::ColorType;
|
||||
use tiff::decoder::{Decoder, DecodingResult};
|
||||
use tiff::encoder::{colortype, TiffEncoder};
|
||||
use tiff::ColorType;
|
||||
|
||||
use std::io::{Seek, SeekFrom};
|
||||
use std::fs::File;
|
||||
use std::io::{Seek, SeekFrom};
|
||||
|
||||
#[test]
|
||||
fn encode_decode() {
|
||||
@@ -23,7 +23,8 @@ fn encode_decode() {
|
||||
{
|
||||
let mut tiff = TiffEncoder::new(&mut file).unwrap();
|
||||
|
||||
tiff.write_image::<colortype::RGB8>(100, 100, &image_data).unwrap();
|
||||
tiff.write_image::<colortype::RGB8>(100, 100, &image_data)
|
||||
.unwrap();
|
||||
}
|
||||
{
|
||||
file.seek(SeekFrom::Start(0)).unwrap();
|
||||
@@ -32,18 +33,16 @@ fn encode_decode() {
|
||||
assert_eq!(decoder.dimensions().unwrap(), (100, 100));
|
||||
if let DecodingResult::U8(img_res) = decoder.read_image().unwrap() {
|
||||
assert_eq!(image_data, img_res);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
panic!("Wrong data type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_gray_u8_roundtrip()
|
||||
{
|
||||
let img_file = File::open("./tests/images/minisblack-1c-8b.tiff").expect("Cannot find test image!");
|
||||
fn test_gray_u8_roundtrip() {
|
||||
let img_file =
|
||||
File::open("./tests/images/minisblack-1c-8b.tiff").expect("Cannot find test image!");
|
||||
let mut decoder = Decoder::new(img_file).expect("Cannot create decoder");
|
||||
assert_eq!(decoder.colortype().unwrap(), ColorType::Gray(8));
|
||||
|
||||
@@ -55,25 +54,24 @@ fn test_gray_u8_roundtrip()
|
||||
let mut file = tempfile::tempfile().unwrap();
|
||||
{
|
||||
let mut tiff = TiffEncoder::new(&mut file).unwrap();
|
||||
|
||||
|
||||
let (width, height) = decoder.dimensions().unwrap();
|
||||
tiff.write_image::<colortype::Gray8>(width, height, &image_data).unwrap();
|
||||
tiff.write_image::<colortype::Gray8>(width, height, &image_data)
|
||||
.unwrap();
|
||||
}
|
||||
file.seek(SeekFrom::Start(0)).unwrap();
|
||||
{
|
||||
let mut decoder = Decoder::new(&mut file).unwrap();
|
||||
if let DecodingResult::U8(img_res) = decoder.read_image().unwrap() {
|
||||
assert_eq!(image_data, img_res);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
panic!("Wrong data type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rgb_u8_roundtrip()
|
||||
{
|
||||
fn test_rgb_u8_roundtrip() {
|
||||
let img_file = File::open("./tests/images/rgb-3c-8b.tiff").expect("Cannot find test image!");
|
||||
let mut decoder = Decoder::new(img_file).expect("Cannot create decoder");
|
||||
assert_eq!(decoder.colortype().unwrap(), ColorType::RGB(8));
|
||||
@@ -86,26 +84,26 @@ fn test_rgb_u8_roundtrip()
|
||||
let mut file = tempfile::tempfile().unwrap();
|
||||
{
|
||||
let mut tiff = TiffEncoder::new(&mut file).unwrap();
|
||||
|
||||
|
||||
let (width, height) = decoder.dimensions().unwrap();
|
||||
tiff.write_image::<colortype::RGB8>(width, height, &image_data).unwrap();
|
||||
tiff.write_image::<colortype::RGB8>(width, height, &image_data)
|
||||
.unwrap();
|
||||
}
|
||||
file.seek(SeekFrom::Start(0)).unwrap();
|
||||
{
|
||||
let mut decoder = Decoder::new(&mut file).unwrap();
|
||||
if let DecodingResult::U8(img_res) = decoder.read_image().unwrap() {
|
||||
assert_eq!(image_data, img_res);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
panic!("Wrong data type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gray_u16_roundtrip()
|
||||
{
|
||||
let img_file = File::open("./tests/images/minisblack-1c-16b.tiff").expect("Cannot find test image!");
|
||||
fn test_gray_u16_roundtrip() {
|
||||
let img_file =
|
||||
File::open("./tests/images/minisblack-1c-16b.tiff").expect("Cannot find test image!");
|
||||
let mut decoder = Decoder::new(img_file).expect("Cannot create decoder");
|
||||
assert_eq!(decoder.colortype().unwrap(), ColorType::Gray(16));
|
||||
|
||||
@@ -117,25 +115,24 @@ fn test_gray_u16_roundtrip()
|
||||
let mut file = tempfile::tempfile().unwrap();
|
||||
{
|
||||
let mut tiff = TiffEncoder::new(&mut file).unwrap();
|
||||
|
||||
|
||||
let (width, height) = decoder.dimensions().unwrap();
|
||||
tiff.write_image::<colortype::Gray16>(width, height, &image_data).unwrap();
|
||||
tiff.write_image::<colortype::Gray16>(width, height, &image_data)
|
||||
.unwrap();
|
||||
}
|
||||
file.seek(SeekFrom::Start(0)).unwrap();
|
||||
{
|
||||
let mut decoder = Decoder::new(&mut file).unwrap();
|
||||
if let DecodingResult::U16(img_res) = decoder.read_image().unwrap() {
|
||||
assert_eq!(image_data, img_res);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
panic!("Wrong data type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rgb_u16_roundtrip()
|
||||
{
|
||||
fn test_rgb_u16_roundtrip() {
|
||||
let img_file = File::open("./tests/images/rgb-3c-16b.tiff").expect("Cannot find test image!");
|
||||
let mut decoder = Decoder::new(img_file).expect("Cannot create decoder");
|
||||
assert_eq!(decoder.colortype().unwrap(), ColorType::RGB(16));
|
||||
@@ -148,17 +145,17 @@ fn test_rgb_u16_roundtrip()
|
||||
let mut file = tempfile::tempfile().unwrap();
|
||||
{
|
||||
let mut tiff = TiffEncoder::new(&mut file).unwrap();
|
||||
|
||||
|
||||
let (width, height) = decoder.dimensions().unwrap();
|
||||
tiff.write_image::<colortype::RGB16>(width, height, &image_data).unwrap();
|
||||
tiff.write_image::<colortype::RGB16>(width, height, &image_data)
|
||||
.unwrap();
|
||||
}
|
||||
file.seek(SeekFrom::Start(0)).unwrap();
|
||||
{
|
||||
let mut decoder = Decoder::new(&mut file).unwrap();
|
||||
if let DecodingResult::U16(img_res) = decoder.read_image().unwrap() {
|
||||
assert_eq!(image_data, img_res);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
panic!("Wrong data type");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user