Skip to content

Commit

Permalink
fixed the testcase having faulty handling of extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Sep 25, 2024
1 parent 8d463c3 commit aced659
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 2 deletions.
4 changes: 2 additions & 2 deletions martin/src/sprites/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ mod tests {

//.sdf => generate sdf from png, add sdf == true
//- => does not generate sdf, omits sdf == true
for extension in [".sdf", ""] {
for extension in ["_sdf", ""] {
test_src(sprites.values(), 1, "all_1", extension).await;
test_src(sprites.values(), 2, "all_2", extension).await;

Expand All @@ -276,7 +276,7 @@ mod tests {
let path = PathBuf::from(format!(
"../tests/fixtures/sprites/expected/{filename}{extension}"
));
let sprites = get_spritesheet(sources, pixel_ratio, extension == ".sdf")
let sprites = get_spritesheet(sources, pixel_ratio, extension == "_sdf")
.await
.unwrap();
let mut json = serde_json::to_string_pretty(sprites.get_index()).unwrap();
Expand Down
34 changes: 34 additions & 0 deletions tests/fixtures/sprites/expected/all_1_sdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"another_bicycle": {
"height": 15,
"pixelRatio": 1,
"width": 15,
"x": 20,
"y": 16,
"sdf": true
},
"bear": {
"height": 16,
"pixelRatio": 1,
"width": 16,
"x": 20,
"y": 0,
"sdf": true
},
"bicycle": {
"height": 15,
"pixelRatio": 1,
"width": 15,
"x": 35,
"y": 16,
"sdf": true
},
"sub/circle": {
"height": 20,
"pixelRatio": 1,
"width": 20,
"x": 0,
"y": 0,
"sdf": true
}
}
Binary file added tests/fixtures/sprites/expected/all_1_sdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions tests/fixtures/sprites/expected/all_2_sdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"another_bicycle": {
"height": 30,
"pixelRatio": 2,
"width": 30,
"x": 40,
"y": 32,
"sdf": true
},
"bear": {
"height": 32,
"pixelRatio": 2,
"width": 32,
"x": 40,
"y": 0,
"sdf": true
},
"bicycle": {
"height": 30,
"pixelRatio": 2,
"width": 30,
"x": 70,
"y": 32,
"sdf": true
},
"sub/circle": {
"height": 40,
"pixelRatio": 2,
"width": 40,
"x": 0,
"y": 0,
"sdf": true
}
}
Binary file added tests/fixtures/sprites/expected/all_2_sdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions tests/fixtures/sprites/expected/src1_1_sdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"another_bicycle": {
"height": 15,
"pixelRatio": 1,
"width": 15,
"x": 20,
"y": 16,
"sdf": true
},
"bear": {
"height": 16,
"pixelRatio": 1,
"width": 16,
"x": 20,
"y": 0,
"sdf": true
},
"sub/circle": {
"height": 20,
"pixelRatio": 1,
"width": 20,
"x": 0,
"y": 0,
"sdf": true
}
}
Binary file added tests/fixtures/sprites/expected/src1_1_sdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions tests/fixtures/sprites/expected/src1_2_sdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"another_bicycle": {
"height": 30,
"pixelRatio": 2,
"width": 30,
"x": 40,
"y": 32,
"sdf": true
},
"bear": {
"height": 32,
"pixelRatio": 2,
"width": 32,
"x": 40,
"y": 0,
"sdf": true
},
"sub/circle": {
"height": 40,
"pixelRatio": 2,
"width": 40,
"x": 0,
"y": 0,
"sdf": true
}
}
Binary file added tests/fixtures/sprites/expected/src1_2_sdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tests/fixtures/sprites/expected/src2_1_sdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bicycle": {
"height": 15,
"pixelRatio": 1,
"width": 15,
"x": 0,
"y": 0,
"sdf": true
}
}
Binary file added tests/fixtures/sprites/expected/src2_1_sdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tests/fixtures/sprites/expected/src2_2_sdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bicycle": {
"height": 30,
"pixelRatio": 2,
"width": 30,
"x": 0,
"y": 0,
"sdf": true
}
}
Binary file added tests/fixtures/sprites/expected/src2_2_sdf.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 aced659

Please sign in to comment.