diff --git a/src/game.rs b/src/game.rs index 87d111e..29aca99 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1,4 +1,5 @@ use crate::{Avatar, Dialogue, Ending, Item, Palette, Room, Sprite, Tile, Variable, mock}; +use std::fs; #[derive(Debug, PartialEq)] pub struct Game { @@ -266,3 +267,50 @@ fn test_add_tile() { assert_eq!(new_id, 1); assert_eq!(game.tiles.len(), 3); } + +#[test] +fn test_bitsy_omnibus() { + let acceptable_failures: Vec = vec![ + // avatar ordering issues + "src/test-resources/omnibus/682993AC.bitsy.txt".to_string(), + "src/test-resources/omnibus/0D901EE6.bitsy.txt".to_string(), + "src/test-resources/omnibus/7FEF71E4.bitsy.txt".to_string(), + "src/test-resources/omnibus/245E93CB.bitsy.txt".to_string(), + "src/test-resources/omnibus/A643C5F4.bitsy.txt".to_string(), + "src/test-resources/omnibus/7533372B.bitsy.txt".to_string(), + "src/test-resources/omnibus/DBD5D375.bitsy.txt".to_string(), + + // fails because of sprite colours but also because a tile contains "NaN" + "src/test-resources/omnibus/DA88C287.bitsy.txt".to_string(), + + // fails because room wall array is not implemented - @todo investigate + // (this game uses room_format 1 - I thought it'd be using 0...) + "src/test-resources/omnibus/76EB6E4A.bitsy.txt".to_string(), + "src/test-resources/omnibus/DC053B1A.bitsy.txt".to_string(), + + // todo handle fonts! + "src/test-resources/omnibus/4B4EB988.bitsy.txt".to_string(), + ]; + + let mut passes = 0; + let mut skips = 0; + + for file in fs::read_dir("src/test-resources/omnibus").unwrap() { + let path = file.unwrap().path(); + let nice_name = format!("{}", path.display()); + + if ! nice_name.contains("bitsy") || acceptable_failures.contains(&nice_name) { + skips += 1; + println!("Skipping: {}", nice_name); + println!("Skipped. {} passes, {} skips.", passes, skips); + continue; + } + + println!("\nTesting: {}...", path.display()); + let game_data = fs::read_to_string(path).unwrap(); + let game = Game::from(game_data.clone()); + assert_eq!(game.to_string().trim(), game_data.trim()); + passes += 1; + println!("Success! {} passes, {} skips.", passes, skips); + } +}