mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-08 08:07:54 -06:00
test: add asset path validity tests
This commit is contained in:
1
.github/workflows/coverage.yaml
vendored
1
.github/workflows/coverage.yaml
vendored
@@ -43,7 +43,6 @@ jobs:
|
|||||||
- uses: taiki-e/install-action@cargo-llvm-cov
|
- uses: taiki-e/install-action@cargo-llvm-cov
|
||||||
- uses: taiki-e/install-action@nextest
|
- uses: taiki-e/install-action@nextest
|
||||||
|
|
||||||
# Note: We manually link zlib. This should be synchronized with the flags set for Linux in .cargo/config.toml.
|
|
||||||
- name: Generate coverage report
|
- name: Generate coverage report
|
||||||
run: |
|
run: |
|
||||||
cargo llvm-cov --no-fail-fast --lcov --output-path lcov.info nextest
|
cargo llvm-cov --no-fail-fast --lcov --output-path lcov.info nextest
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
//! On desktop, assets are embedded using include_bytes!; on Emscripten, assets are loaded from the filesystem.
|
//! On desktop, assets are embedded using include_bytes!; on Emscripten, assets are loaded from the filesystem.
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use strum_macros::EnumIter;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter)]
|
||||||
pub enum Asset {
|
pub enum Asset {
|
||||||
Wav1,
|
Wav1,
|
||||||
Wav2,
|
Wav2,
|
||||||
|
|||||||
14
tests/asset.rs
Normal file
14
tests/asset.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
use pacman::asset::Asset;
|
||||||
|
use std::path::Path;
|
||||||
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_asset_paths_valid() {
|
||||||
|
let base_path = Path::new("assets/game/");
|
||||||
|
|
||||||
|
for asset in Asset::iter() {
|
||||||
|
let path = base_path.join(asset.path());
|
||||||
|
assert!(path.exists(), "Asset path does not exist: {:?}", path);
|
||||||
|
assert!(path.is_file(), "Asset path is not a file: {:?}", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user