1#[cfg(test)]
2mod tests {
3 use crate::exif::{create_list_from_vec, exiftool_available, Exif, Mode};
4 use std::path::Path;
5
6 pub const TEST_FILE_PATH: &str =
7 r"C:\Users\Alexi Peck\Desktop\mapping_tool\target\release\source_one\DJI_0013.JPG";
8
9 #[test]
10 fn test_exiftool_available() {
11 if !exiftool_available() {
12 panic!("Exiftool not available for execution.");
13 }
14 }
15
16 #[test]
17 fn test_pull_exif_data_all() {
18 println!("Starting test.");
19 match Exif::new(Path::new(TEST_FILE_PATH), Mode::All) {
20 Ok(exif) => {
21 for (tag, value) in exif.attributes.iter() {
22 println!("{}:{}", tag, value);
23 }
24 }
25 Err(err) => {
26 panic!("{}", err);
27 }
28 };
29 println!("Ending test.");
30 }
31
32 #[test]
33 fn test_pull_exif_data_whitelist() {
34 println!("Starting test.");
35 let whitelist = create_list_from_vec(vec![
36 "GPSLatitude",
37 "GPSLongitude",
38 "GPSAltitude",
39 "ExifImageWidth",
40 "ExifImageHeight",
41 "FlightYawDegree",
42 "AbsoluteAltitude",
43 "RelativeAltitude",
44 "FieldOfView",
45 "FocalLength",
46 ]);
47 match Exif::new(Path::new(TEST_FILE_PATH), Mode::Whitelist(whitelist)) {
48 Ok(exif) => {
49 for (tag, value) in exif.attributes.iter() {
50 println!("{}:{}", tag, value);
51 }
52 }
53 Err(err) => {
54 panic!("{}", err);
55 }
56 };
57 println!("Ending test.");
58 }
59
60 #[test]
61 fn test_pull_exif_data_blacklist() {
62 println!("Starting test.");
63 let blacklist = create_list_from_vec(vec![
64 "SerialNumber",
65 "FileModificationDate/Time",
66 "DigitalZoomRatio",
67 "XPComment",
68 "XPKeywords",
69 ]);
70 match Exif::new(Path::new(TEST_FILE_PATH), Mode::Blacklist(blacklist)) {
71 Ok(exif) => {
72 for (tag, value) in exif.attributes.iter() {
73 println!("{}:{}", tag, value);
74 }
75 }
76 Err(err) => {
77 panic!("{}", err);
78 }
79 };
80 println!("Ending test.");
81 }
82}