Skip to content

Commit f06e773

Browse files
committed
tidy up tests
1 parent cdd7511 commit f06e773

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

tests/jpeg-read.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use std::error::Error;
2+
use std::path::Path;
3+
4+
use iptc::IPTC;
5+
use iptc::IPTCTag;
6+
7+
#[test]
8+
fn exiv2_iptc_example() -> Result<(), Box<dyn Error>> {
9+
// https://exiv2.org/examples.html
10+
// Example 3: iptcprint.cpp
11+
12+
let image_path = Path::new("tests/smiley.jpg");
13+
let iptc = IPTC::read_from_path(&image_path)?;
14+
15+
let tags = iptc.get_all();
16+
println!("IPTC: {:?}", tags);
17+
18+
let keywords = iptc.get(IPTCTag::Keywords);
19+
assert_eq!(keywords, "Yet another keyword");
20+
21+
let date_created = iptc.get(IPTCTag::DateCreated);
22+
assert_eq!(date_created, "20040803");
23+
24+
let urgency = iptc.get(IPTCTag::Urgency);
25+
assert_eq!(urgency, "very!");
26+
27+
let model_version = iptc.get(IPTCTag::ModelVersion);
28+
assert_eq!(model_version, "42");
29+
30+
let time_sent = iptc.get(IPTCTag::TimeSent);
31+
assert_eq!(time_sent, "144100-0500");
32+
33+
Ok(())
34+
}

tests/smiley.rs renamed to tests/jpeg-write.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,6 @@ use std::path::Path;
55
use iptc::IPTC;
66
use iptc::IPTCTag;
77

8-
#[test]
9-
fn exiv2_iptc_example() -> Result<(), Box<dyn Error>> {
10-
// https://exiv2.org/examples.html
11-
// Example 3: iptcprint.cpp
12-
13-
let image_path = Path::new("tests/smiley.jpg");
14-
let iptc = IPTC::read_from_path(&image_path)?;
15-
16-
let tags = iptc.get_all();
17-
println!("IPTC: {:?}", tags);
18-
19-
let keywords = iptc.get(IPTCTag::Keywords);
20-
assert_eq!(keywords, "Yet another keyword");
21-
22-
let date_created = iptc.get(IPTCTag::DateCreated);
23-
assert_eq!(date_created, "20040803");
24-
25-
let urgency = iptc.get(IPTCTag::Urgency);
26-
assert_eq!(urgency, "very!");
27-
28-
let model_version = iptc.get(IPTCTag::ModelVersion);
29-
assert_eq!(model_version, "42");
30-
31-
let time_sent = iptc.get(IPTCTag::TimeSent);
32-
assert_eq!(time_sent, "144100-0500");
33-
34-
Ok(())
35-
}
36-
378
#[test]
389
fn test_write_iptc() -> Result<(), Box<dyn Error>> {
3910
// Create a copy of the test file so we don't modify the original

0 commit comments

Comments
 (0)