Skip to content

Commit

Permalink
add basic test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
B-Reif committed Jul 17, 2021
1 parent 1880d09 commit 37d758a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ mod ase;
pub mod aseloader;
mod processing;
mod sprite;
#[cfg(test)]
mod tests;
mod tileset;
pub mod timer;

#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
pub use ase::AseId;
pub use tileset::{TileSize, Tileset, TilesetId, TilesetKey};
2 changes: 1 addition & 1 deletion src/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bevy::sprite::TextureAtlasBuilder;
use std::time::Instant;
use std::{collections::HashMap, path::PathBuf};

pub(crate) struct TilesetsByKey<T>(HashMap<TilesetKey, TilesetData<T>>);
pub(crate) struct TilesetsByKey<T>(pub HashMap<TilesetKey, TilesetData<T>>);
impl TilesetsByKey<Texture> {
fn new() -> Self {
Self(HashMap::new())
Expand Down
29 changes: 29 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::path::PathBuf;

use asefile::AsepriteFile;

use crate::processing;

fn test_path(name: &str) -> PathBuf {
let mut path = PathBuf::new();
path.push("tests");
path.push("data");
path.push(format!("{}.aseprite", name));
path
}

fn load_test_file(path: &PathBuf) -> AsepriteFile {
println!("Loading file: {}", path.display());
AsepriteFile::read_file(path).unwrap()
}

#[test]
fn tileset_file() {
let path = test_path("tileset");
let ase = load_test_file(&path);
let mut inputs = Vec::new();
inputs.push((path, ase));
let assets = processing::AseAssets::new(inputs);
let tilesets = assets.tilesets.0;
assert_eq!(tilesets.len(), 1);
}
Binary file added tests/data/tileset.aseprite
Binary file not shown.

0 comments on commit 37d758a

Please sign in to comment.