From bc229d478ac124236b3a80aff5ca811ad90d9cd4 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Mon, 14 Sep 2015 13:24:03 -0500 Subject: [PATCH] Changed product name to pihash for more convienient writing in functions. Updated the unit test to confirm that there are 12 test images --- src/lib.rs | 19 ++++++++++++++++--- src/main.rs | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 001317f..404793c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,11 +24,24 @@ mod tests { let paths = fs::read_dir(&path::Path::new("./test_images")).unwrap(); let mut num_paths = 0; for path in paths { - num_paths += 1; + let orig_path = path.unwrap().path(); + let ext = path::Path::new(&orig_path).extension(); + match ext { + Some(_) => { + if ext.unwrap() == "jpg" { + println!("Is a image {}: {:?}", num_paths, orig_path) ; + num_paths += 1; + } + }, + _ => { + println!("Not an image: {:?}", orig_path) ; + continue + } + } //println!("Name: {}", path.unwrap().path().display()) } - // Currently 13 files in the test imaages directory - assert!(num_paths >= 13); + // Currently 12 images in the test imaages directory + assert!(num_paths == 12); } } diff --git a/src/main.rs b/src/main.rs index aa8211b..35db5b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,10 +3,10 @@ // Licensed under the MIT license. // This file may not be copied, modified, or distributed except according to those terms. -extern crate perceptual_image_hashing; +extern crate pihash; fn main() { let mut string = String::new(); - string = perceptual_image_hashing::hello(string); + string = pihash::hello(string); println!("{}",string); }