Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkAndshark committed Feb 10, 2025
1 parent fb3dca2 commit 81fab0f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions martin/src/cog/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ mod tests {
"../tests/fixtures/cog/expected/right_padded.png",
3,
0,
None,
128,
256,
256,
Expand All @@ -414,6 +415,7 @@ mod tests {
"../tests/fixtures/cog/expected/down_padded.png",
3,
0,
None,
256,
128,
256,
Expand All @@ -424,6 +426,7 @@ mod tests {
"../tests/fixtures/cog/expected/down_padded_with_alpha.png",
4,
128,
None,
256,
128,
256,
Expand All @@ -434,25 +437,39 @@ mod tests {
"../tests/fixtures/cog/expected/right_padded_with_alpha.png",
4,
128,
None,
128,
256,
256,
256
)]
// should be all gray
#[case(
"../tests/fixtures/cog/expected/not_padded_all.png",
"../tests/fixtures/cog/expected/not_padded.png",
4,
128,
None,
256,
256,
256,
256
)]
// not padded and with a no_data whose value is 128, and all the component is 128, so that should be all transprent
#[case(
"../tests/fixtures/cog/expected/all_transprent.png",
4,
128, //default value
Some(128), // no_data
128,
128,
256,
256
)]
fn test_padded_cases(
#[case] expected_file_path: &str,
#[case] componses_count: u32,
#[case] default_value: u8,
#[case] no_value: Option<u8>,
#[case] data_width: u32,
#[case] data_height: u32,
#[case] tile_width: u32,
Expand All @@ -464,7 +481,7 @@ mod tests {
(tile_width, tile_height),
(data_width, data_height),
componses_count,
None,
no_value,
&PathBuf::from("not_exist.tif"),
)
.unwrap();
Expand Down
Binary file added tests/fixtures/cog/expected/all_transprent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/fixtures/cog/expected/not_padded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 81fab0f

Please sign in to comment.