blob: c246ed2822be1985bc637a534bb7eb72b47482d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
pub mod tiff;
pub mod binfile;
pub mod label_formats;
pub const TEST_IMAGE_PATH: &str = "../test.tif";
pub const TEST_OUTPUT_PATH: &str = "../test.bin";
pub const TEST_LABEL_OUTPUT_PATH: &str = "../test.c.bin";
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(0, 0);
}
#[test]
fn ignore_warning_test() {
tiff::ignore_warnings();
assert_eq!(0, 0);
}
#[test]
fn tiff_open_test() {
tiff::ignore_warnings();
if let Some(result) = tiff::open(TEST_IMAGE_PATH) {
tiff::close(result);
} else {
assert!(false);
}
}
#[test]
fn tiff_width_test() {
tiff::ignore_warnings();
if let Some(t_handle) = tiff::open(TEST_IMAGE_PATH) {
let width = tiff::get_image_width(t_handle).expect("Image should have width!");
assert!(width > 0);
tiff::close(t_handle);
} else {
assert!(false);
}
}
#[test]
fn tiff_height_test() {
tiff::ignore_warnings();
if let Some(t_handle) = tiff::open(TEST_IMAGE_PATH) {
let height = tiff::get_image_height(t_handle).expect("Image should have height!");
assert!(height > 0);
tiff::close(t_handle);
} else {
assert!(false);
}
}
#[test]
fn tiff_channel_test() {
tiff::ignore_warnings();
if let Some(t_handle) = tiff::open(TEST_IMAGE_PATH) {
let channels = tiff::get_image_channels(t_handle);
assert!(channels > 0);
tiff::close(t_handle);
} else {
assert!(false);
}
}
#[test]
fn tiff_read_test() {
tiff::ignore_warnings();
if let Some(t_handle) = tiff::open(TEST_IMAGE_PATH) {
let _data = tiff::read(t_handle);
tiff::close(t_handle);
} else {
assert!(false);
}
}
#[test]
fn tiff_data_dump_test() {
tiff::ignore_warnings();
if let Some(large_label_format) = tiff::to_large_labels(TEST_IMAGE_PATH) {
println!("{:?}", large_label_format);
let data = large_label_format.buffer;
binfile::dump_u32_vec(TEST_OUTPUT_PATH, data).expect("File output error");
} else {
assert!(false);
}
}
#[test]
fn tiff_compressed_data_dump_test() {
tiff::ignore_warnings();
if let Some(large_label_format) = tiff::to_large_labels(TEST_IMAGE_PATH) {
let compressed_format = large_label_format.compress();
let data = compressed_format.buffer;
binfile::dump_u16_vec(TEST_LABEL_OUTPUT_PATH, data).expect("File output error");
} else {
assert!(false);
}
}
}
|