removes uncompressed test results as deflated version is now being used
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
mod test_utils;
|
||||
use std::path::Path;
|
||||
use crate::test_utils::load_compressed_result;
|
||||
use crate::test_utils::load_rom;
|
||||
use gemma::chip8::computer::Chip8Computer;
|
||||
use gemma::chip8::computer_manager::Chip8ComputerManager;
|
||||
use gemma::chip8::quirk_modes::QuirkMode;
|
||||
use gemma::chip8::quirk_modes::QuirkMode::{Chip8, SChipModern, XOChip};
|
||||
use gemma::chip8::registers::Chip8Registers;
|
||||
use gemma::constants::{CHIP8_VIDEO_MEMORY, TEST_ROM_ROOT};
|
||||
use crate::test_utils::{load_compressed_result, load_result, load_rom};
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
assert!(true)
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn reset_clears_video() {
|
||||
let mut x = Chip8Computer::new();
|
||||
@@ -35,7 +34,7 @@ fn reset_clears_video() {
|
||||
#[test]
|
||||
fn level1_test() {
|
||||
let mut x = Chip8Computer::new();
|
||||
let level_1_rom = load_rom("1-chip8-logo.ch8");
|
||||
let level_1_rom = load_rom("1-chip8-logo");
|
||||
x.load_bytes_to_memory(0x200, &level_1_rom);
|
||||
|
||||
// run for 0x40 cycles
|
||||
@@ -44,7 +43,7 @@ fn level1_test() {
|
||||
}
|
||||
assert_eq!(
|
||||
x.dump_video_to_string(),
|
||||
load_result("gemma_integration_level_1_test.asc")
|
||||
load_compressed_result("gemma_integration_level_1_test")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,8 +52,7 @@ fn level2_test() {
|
||||
let mut x = Chip8Computer::new();
|
||||
// Load the IBM rom and run it.
|
||||
// it takes 39 cycles to get to the end so lets run it 40.
|
||||
let test_rom_to_run = load_rom("2-ibm-logo.ch8");
|
||||
x.load_bytes_to_memory(0x200, &test_rom_to_run);
|
||||
x.load_bytes_to_memory(0x200, &load_rom("2-ibm-logo"));
|
||||
for _ in 0..40 {
|
||||
x.step_system();
|
||||
}
|
||||
@@ -63,7 +61,7 @@ fn level2_test() {
|
||||
|
||||
assert_eq!(
|
||||
x.dump_video_to_string(),
|
||||
load_result("gemma_integration_ibm_rom_output.asc")
|
||||
load_compressed_result("gemma_integration_ibm_rom_output")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,14 +69,14 @@ fn level2_test() {
|
||||
fn level3_test() {
|
||||
let mut x = Chip8Computer::new();
|
||||
|
||||
x.load_bytes_to_memory(0x200, &load_rom("3-corax+.ch8"));
|
||||
x.load_bytes_to_memory(0x200, &load_rom("3-corax+"));
|
||||
for _ in 0..0x180 {
|
||||
x.step_system();
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
x.dump_video_to_string(),
|
||||
load_result("gemma_integration_corax_plus.asc")
|
||||
load_compressed_result("gemma_integration_corax_plus")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,21 +84,21 @@ fn level3_test() {
|
||||
fn level3_compressed_test() {
|
||||
let mut x = Chip8Computer::new();
|
||||
|
||||
x.load_bytes_to_memory(0x200, &load_rom("3-corax+.ch8"));
|
||||
x.load_bytes_to_memory(0x200, &load_rom("3-corax+"));
|
||||
for _ in 0..0x180 {
|
||||
x.step_system();
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
x.dump_video_to_string(),
|
||||
load_compressed_result("gemma_integration.corax_plus.deflated")
|
||||
load_compressed_result("gemma_integration.corax_plus")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rps_test() {
|
||||
let mut x = Chip8Computer::new();
|
||||
x.load_bytes_to_memory(0x200, &load_rom("RPS.ch8"));
|
||||
x.load_bytes_to_memory(0x200, &load_rom("RPS"));
|
||||
for _ in 0..0xF0 {
|
||||
x.step_system();
|
||||
}
|
||||
@@ -122,14 +120,14 @@ fn rps_test() {
|
||||
fn level4_test() {
|
||||
// flags
|
||||
let mut x = Chip8Computer::new();
|
||||
x.load_bytes_to_memory(0x200, &load_rom("4-flags.ch8"));
|
||||
x.load_bytes_to_memory(0x200, &load_rom("4-flags"));
|
||||
for _ in 0..0x400 {
|
||||
x.step_system();
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
x.dump_video_to_string(),
|
||||
load_result("gemma_integration_flags.asc")
|
||||
load_compressed_result("gemma_integration_flags")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -137,16 +135,25 @@ fn level4_test() {
|
||||
fn registers_equality() {
|
||||
let data_set: Vec<(Chip8Registers, Chip8Registers, bool)> = vec![
|
||||
(Chip8Registers::default(), Chip8Registers::default(), true),
|
||||
(Chip8Registers {
|
||||
registers: [0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00,],
|
||||
(
|
||||
Chip8Registers {
|
||||
registers: [
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
],
|
||||
i_register: 0,
|
||||
pc: 0,
|
||||
},
|
||||
Chip8Registers {
|
||||
registers:[0x01, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00,],
|
||||
i_register: 0,
|
||||
pc: 0,
|
||||
}, false)
|
||||
Chip8Registers {
|
||||
registers: [
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
],
|
||||
i_register: 0,
|
||||
pc: 0,
|
||||
},
|
||||
false,
|
||||
),
|
||||
];
|
||||
|
||||
for (first, second, matches) in data_set.iter() {
|
||||
@@ -187,7 +194,7 @@ fn load_rom_allows_starting() {
|
||||
let mut new_manager = Chip8ComputerManager::default();
|
||||
assert!(!new_manager.core_should_run);
|
||||
let p = TEST_ROM_ROOT.to_string() + "/1-chip8-logo.ch8";
|
||||
let full_path = Path::new(p.as_str());
|
||||
let full_path = Path::new(p.as_str());
|
||||
new_manager.load_new_program_from_disk_to_system_memory(full_path);
|
||||
assert!(new_manager.core_should_run)
|
||||
}
|
||||
@@ -195,7 +202,10 @@ fn load_rom_allows_starting() {
|
||||
#[test]
|
||||
fn reset_clears_run_state() {
|
||||
let mut new_manager = Chip8ComputerManager::default();
|
||||
let p = format!("{}/../resources/test/roms/1-chip8-logo.ch8", std::env::current_dir().unwrap().display());
|
||||
let p = format!(
|
||||
"{}/../resources/test/roms/1-chip8-logo.ch8",
|
||||
std::env::current_dir().unwrap().display()
|
||||
);
|
||||
new_manager.load_new_program_from_disk_to_system_memory(Path::new(p.as_str()));
|
||||
new_manager.reset(QuirkMode::Chip8);
|
||||
assert!(!new_manager.core_should_run);
|
||||
@@ -205,9 +215,13 @@ fn reset_clears_run_state() {
|
||||
fn tick_when_ready() {
|
||||
let mut new_manager = Chip8ComputerManager::default();
|
||||
new_manager.load_new_program_from_disk_to_system_memory(Path::new(
|
||||
format!("{}/../resources/test/roms/1-chip8-logo.ch8", std::env::current_dir().unwrap().display()).as_str()));
|
||||
format!(
|
||||
"{}/../resources/test/roms/1-chip8-logo.ch8",
|
||||
std::env::current_dir().unwrap().display()
|
||||
)
|
||||
.as_str(),
|
||||
));
|
||||
assert!(new_manager.core_should_run);
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
use std::fs;
|
||||
mod test_utils;
|
||||
use crate::test_utils::read_test_result;
|
||||
use gemma::chip8::computer::Chip8Computer;
|
||||
use std::fs;
|
||||
use std::io::prelude::*;
|
||||
|
||||
fn load_result(to_load: &str) -> String {
|
||||
let full_path = format!("{}/../resources/test/state/{}", std::env::current_dir().unwrap().display(), to_load);
|
||||
println!("CURRENT DIR: {:?}", std::env::current_dir());
|
||||
println!("Loading state => (([{}]))", full_path);
|
||||
std::fs::read_to_string(full_path).unwrap()
|
||||
}
|
||||
|
||||
fn load_rom(to_load: &str) -> Vec<u8> {
|
||||
fs::read(format!("resources/test/roms/{}", to_load)).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn serialization_round_trip() {
|
||||
let original_computer = Chip8Computer::new();
|
||||
let expected_json = load_result("smoke_001_round_trip_serialize_deserialize.json");
|
||||
let expected_json = read_test_result("smoke_001_round_trip_serialize_deserialize.json");
|
||||
|
||||
// Serialize the Chip8Computer instance
|
||||
let serialized = serde_json::to_string(&original_computer).expect("Serialization failed");
|
||||
@@ -33,10 +24,10 @@ fn serialization_round_trip() {
|
||||
// Deserialize back to Chip8Computer and assert equality
|
||||
let deserialized_computer: Chip8Computer =
|
||||
serde_json::from_str(&serialized).expect("Deserialization failed");
|
||||
assert_eq!(
|
||||
deserialized_computer, original_computer,
|
||||
"Deserialized instance does not match the original"
|
||||
);
|
||||
assert_eq!(
|
||||
deserialized_computer, original_computer,
|
||||
"Deserialized instance does not match the original"
|
||||
);
|
||||
}
|
||||
//
|
||||
// #[test]
|
||||
|
||||
+67
-18
@@ -1,15 +1,16 @@
|
||||
use flate2::read::DeflateDecoder;
|
||||
use flate2::write::DeflateEncoder;
|
||||
use flate2::Compression;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use flate2::Compression;
|
||||
use flate2::read::DeflateDecoder;
|
||||
use flate2::write::{DeflateEncoder};
|
||||
|
||||
|
||||
use tempfile::tempfile;
|
||||
const TEST_OUTPUT_SAMPLE_DIR: &str = "../resources/test/";
|
||||
|
||||
pub fn compress_string(input: &str) -> Vec<u8> {
|
||||
let mut encoder = DeflateEncoder::new(Vec::new(), Compression::default());
|
||||
encoder.write_all(input.as_bytes()).expect("Failed to write data");
|
||||
encoder
|
||||
.write_all(input.as_bytes())
|
||||
.expect("Failed to write data");
|
||||
encoder.finish().expect("Failed to finish compression")
|
||||
}
|
||||
|
||||
@@ -23,11 +24,18 @@ pub fn decompress_to_string(compressed_data: &[u8]) -> Result<String, std::io::E
|
||||
/// Read a compressed test result and return the expected result
|
||||
/// as a string
|
||||
pub fn read_compressed_test_result(suffix: &str) -> String {
|
||||
let full_path = std::env::current_dir().unwrap().display().to_string() + "/" + &*TEST_OUTPUT_SAMPLE_DIR.to_owned() + suffix + ".deflated";
|
||||
let full_path = std::env::current_dir().unwrap().display().to_string()
|
||||
+ "/"
|
||||
+ &*TEST_OUTPUT_SAMPLE_DIR.to_owned()
|
||||
+ suffix
|
||||
+ ".deflated";
|
||||
println!("LOADING {}", full_path);
|
||||
let mut compressed_file = File::open(full_path).expect(format!("Unable to load test result [{}]", suffix).as_str());
|
||||
let mut compressed_file = File::open(&full_path)
|
||||
.expect(format!("Unable to load test result [{}]", full_path.clone()).as_str());
|
||||
let mut compressed_data = Vec::new();
|
||||
compressed_file.read_to_end(&mut compressed_data).expect("Unable to compress data");
|
||||
compressed_file
|
||||
.read_to_end(&mut compressed_data)
|
||||
.expect("Unable to compress data");
|
||||
|
||||
decompress_to_string(&compressed_data).unwrap()
|
||||
}
|
||||
@@ -35,16 +43,57 @@ pub fn read_compressed_test_result(suffix: &str) -> String {
|
||||
pub fn load_compressed_result(suffix: &str) -> String {
|
||||
read_compressed_test_result(suffix)
|
||||
}
|
||||
|
||||
pub fn read_test_result(suffix: &str) -> String {
|
||||
std::fs::read_to_string(TEST_OUTPUT_SAMPLE_DIR.to_owned() + suffix).unwrap()
|
||||
}
|
||||
|
||||
|
||||
pub fn load_result(to_load: &str) -> String {
|
||||
std::fs::read_to_string(format!("../resources/test/{}", to_load)).unwrap()
|
||||
panic!("THIS SHOULD BE COMPRESSED.");
|
||||
// let full_path = TEST_OUTPUT_SAMPLE_DIR.to_owned() + suffix;
|
||||
// println!("READING TEST RESULTS FROM {}", full_path);
|
||||
// std::fs::read_to_string(full_path).unwrap()
|
||||
}
|
||||
|
||||
pub fn load_rom(to_load: &str) -> Vec<u8> {
|
||||
std::fs::read(format!("../resources/roms/{}", to_load)).unwrap()
|
||||
}
|
||||
std::fs::read(format!("../resources/roms/{}.ch8", to_load)).unwrap()
|
||||
}
|
||||
|
||||
fn load_result(to_load: &str) -> String {
|
||||
panic!("THIS SHOULD BE COMPRESSED.");
|
||||
// let full_path = format!(
|
||||
// "{}/../resources/test/state/{}",
|
||||
// std::env::current_dir().unwrap().display(),
|
||||
// to_load
|
||||
// );
|
||||
// println!("CURRENT DIR: {:?}", std::env::current_dir());
|
||||
// println!("Loading state => (([{}]))", full_path);
|
||||
// std::fs::read_to_string(full_path).unwrap()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
assert!(true)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compression_round_trip() {
|
||||
let to_compress = "The quick brown fox jumps over the lazy dog.";
|
||||
|
||||
let compressed_text = compress_string(to_compress);
|
||||
let decompressed_text = decompress_to_string(&compressed_text).unwrap();
|
||||
assert_eq!(to_compress, decompressed_text);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_compression_round_trip() {
|
||||
// compress string to file...
|
||||
let string_to_compress = "The quick brown fox jumps over the lazy dog.";
|
||||
let compressed_string = compress_string(string_to_compress);
|
||||
let temp_target = tempfile().unwrap();
|
||||
|
||||
//
|
||||
// ...decompress from file...
|
||||
//
|
||||
// ...verify its the same.
|
||||
}
|
||||
}
|
||||
|
||||
+40
-34
@@ -1,6 +1,6 @@
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use crate::test_utils::{load_compressed_result, read_test_result};
|
||||
use gemma::chip8::computer::Chip8Computer;
|
||||
use gemma::chip8::computer_manager::Chip8ComputerManager;
|
||||
use gemma::chip8::cpu_states::Chip8CpuStates::WaitingForInstruction;
|
||||
use gemma::chip8::delay_timer::DelayTimer;
|
||||
use gemma::chip8::instructions::Chip8CpuInstructions;
|
||||
@@ -17,8 +17,9 @@ use gemma::constants::*;
|
||||
use log::debug;
|
||||
use rand::random;
|
||||
use serde::Serialize;
|
||||
use gemma::chip8::computer_manager::Chip8ComputerManager;
|
||||
use crate::test_utils::read_test_result;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use test_utils::read_compressed_test_result;
|
||||
|
||||
mod test_utils;
|
||||
|
||||
@@ -36,7 +37,10 @@ fn decoder_test_invalid_instructions() {
|
||||
];
|
||||
|
||||
for i in invalid_to_encode {
|
||||
assert_eq!(Chip8CpuInstructions::decode(i, &Chip8).encode(), XXXXERRORINSTRUCTION_ENCODED);
|
||||
assert_eq!(
|
||||
Chip8CpuInstructions::decode(i, &Chip8).encode(),
|
||||
XXXXERRORINSTRUCTION_ENCODED
|
||||
);
|
||||
assert!(matches!(
|
||||
Chip8CpuInstructions::decode(i, &Chip8),
|
||||
Chip8CpuInstructions::XXXXERRORINSTRUCTION
|
||||
@@ -694,7 +698,7 @@ fn keypad_string_format_test() {
|
||||
|
||||
assert_eq!(
|
||||
k.format_as_string(),
|
||||
read_test_result("gemma_keypad_string_result.asc")
|
||||
read_compressed_test_result("gemma_keypad_string_result")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1111,7 +1115,7 @@ fn video_write_checkboard() {
|
||||
let v = build_checkerboard();
|
||||
assert_eq!(
|
||||
v.clone().format_as_string(),
|
||||
read_test_result("test_video_write_checkerboard.asc")
|
||||
load_compressed_result("test_video_write_checkerboard")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1124,7 +1128,7 @@ fn video_zero_test() {
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
read_test_result("test_video_zero.asc"),
|
||||
load_compressed_result("test_video_zero"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1151,7 +1155,7 @@ fn video_multi_sprite_test() {
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
read_test_result("test_multi_sprite.asc"),
|
||||
load_compressed_result("test_multi_sprite"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1162,7 +1166,7 @@ fn video_reset_test() {
|
||||
x.reset();
|
||||
assert_eq!(
|
||||
x.format_as_string(),
|
||||
read_test_result("test_reset_clears_video.asc")
|
||||
load_compressed_result("test_reset_clears_video")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1221,7 +1225,7 @@ fn video_scroll_down_1_row_test() {
|
||||
let mut x = build_checkerboard();
|
||||
x.scroll_down(1);
|
||||
assert_eq!(
|
||||
read_test_result("test_video_scroll_down_1.asc"),
|
||||
load_compressed_result("test_video_scroll_down_1"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1231,7 +1235,7 @@ fn video_scroll_down_10_row_test() {
|
||||
let mut x = build_checkerboard();
|
||||
x.scroll_down(10);
|
||||
assert_eq!(
|
||||
read_test_result("test_video_scroll_down_10.asc"),
|
||||
load_compressed_result("test_video_scroll_down_10"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1241,7 +1245,7 @@ fn video_high_res_has_right_resolution() {
|
||||
let x = build_checkboard_hd();
|
||||
println!("[{}]", x.format_as_string());
|
||||
assert_eq!(
|
||||
read_test_result("test_video_highdef.asc"),
|
||||
load_compressed_result("test_video_highdef"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1251,11 +1255,8 @@ fn video_scroll_down_1_row_test_schip() {
|
||||
let mut x = build_checkboard_hd();
|
||||
x.scroll_down(1);
|
||||
|
||||
println!("[{}]", x.format_as_string());
|
||||
println!("[{}]", read_test_result("test_scroll_down_1_hd.asc"));
|
||||
|
||||
assert_eq!(
|
||||
read_test_result("test_scroll_down_1_hd.asc"),
|
||||
load_compressed_result("test_scroll_down_1_hd"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1265,7 +1266,7 @@ fn video_scroll_down_10_row_test_schip() {
|
||||
let mut x = build_checkboard_hd();
|
||||
x.scroll_down(10);
|
||||
assert_eq!(
|
||||
read_test_result("test_scroll_down_10_hd.asc"),
|
||||
load_compressed_result("test_scroll_down_10_hd"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1275,7 +1276,7 @@ fn video_scroll_left_4_row_test_std_def() {
|
||||
let mut x = build_checkerboard();
|
||||
x.scroll_left();
|
||||
assert_eq!(
|
||||
read_test_result("test_scroll_left_4.asc"),
|
||||
load_compressed_result("test_scroll_left_4"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1285,7 +1286,7 @@ fn video_scroll_left_4_row_test_high_def() {
|
||||
let mut x = build_checkboard_hd();
|
||||
x.scroll_left();
|
||||
assert_eq!(
|
||||
read_test_result("test_scroll_left_4_hd.asc"),
|
||||
load_compressed_result("test_scroll_left_4_hd"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1295,7 +1296,7 @@ fn video_scroll_right_4_row_test_std_def() {
|
||||
let mut x = build_checkerboard();
|
||||
x.scroll_right();
|
||||
assert_eq!(
|
||||
read_test_result("test_scroll_right_4.asc"),
|
||||
load_compressed_result("test_scroll_right_4"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1305,7 +1306,7 @@ fn video_scroll_right_4_row_test_high_def() {
|
||||
let mut x = build_checkboard_hd();
|
||||
x.scroll_right();
|
||||
assert_eq!(
|
||||
read_test_result("test_scroll_right_4_hd.asc"),
|
||||
load_compressed_result("test_scroll_right_4_hd"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1342,7 +1343,7 @@ fn instruction_test_scrolling_lowres() {
|
||||
x.quirk_mode = quirk.clone();
|
||||
Chip8CpuInstructions::SCR.execute(&mut x);
|
||||
assert_eq!(
|
||||
read_test_result("test_scroll_right_4.asc"),
|
||||
load_compressed_result("test_scroll_right_4"),
|
||||
x.dump_video_to_string()
|
||||
);
|
||||
|
||||
@@ -1352,7 +1353,7 @@ fn instruction_test_scrolling_lowres() {
|
||||
Chip8CpuInstructions::SCL.execute(&mut x);
|
||||
|
||||
assert_eq!(
|
||||
read_test_result("test_scroll_left_4.asc"),
|
||||
load_compressed_result("test_scroll_left_4"),
|
||||
x.dump_video_to_string()
|
||||
);
|
||||
|
||||
@@ -1361,7 +1362,7 @@ fn instruction_test_scrolling_lowres() {
|
||||
x.quirk_mode = quirk.clone();
|
||||
Chip8CpuInstructions::SCD(0x01).execute(&mut x);
|
||||
assert_eq!(
|
||||
read_test_result("test_video_scroll_down_1.asc"),
|
||||
load_compressed_result("test_video_scroll_down_1"),
|
||||
x.dump_video_to_string()
|
||||
);
|
||||
|
||||
@@ -1370,7 +1371,7 @@ fn instruction_test_scrolling_lowres() {
|
||||
x.quirk_mode = quirk.clone();
|
||||
Chip8CpuInstructions::SCD(0xA).execute(&mut x);
|
||||
assert_eq!(
|
||||
read_test_result("test_video_scroll_down_10.asc"),
|
||||
load_compressed_result("test_video_scroll_down_10"),
|
||||
x.dump_video_to_string()
|
||||
);
|
||||
}
|
||||
@@ -1382,7 +1383,7 @@ fn computer_dump_keypad_to_string() {
|
||||
x.keypad.push_key(0x1);
|
||||
x.keypad.push_key(0x2);
|
||||
assert_eq!(
|
||||
read_test_result("test_keypad_to_string.asc"),
|
||||
load_compressed_result("test_keypad_to_string"),
|
||||
x.dump_keypad_to_string()
|
||||
);
|
||||
}
|
||||
@@ -1410,7 +1411,7 @@ fn video_scroll_up_tests_sd() {
|
||||
let distance = 1u8;
|
||||
x.scroll_up(&distance);
|
||||
assert_eq!(
|
||||
read_test_result("test_video_scroll_up_test_sd.asc"),
|
||||
load_compressed_result("test_video_scroll_up_test_sd"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1421,7 +1422,7 @@ fn video_scroll_up_tests_hd() {
|
||||
let distance = 1u8;
|
||||
x.scroll_up(&distance);
|
||||
assert_eq!(
|
||||
read_test_result("test_video_scroll_up_test_hd.asc"),
|
||||
load_compressed_result("test_video_scroll_up_test_hd"),
|
||||
x.format_as_string()
|
||||
);
|
||||
}
|
||||
@@ -1523,7 +1524,6 @@ fn video_highres_schip_draw_chip8_sprite() {}
|
||||
#[test]
|
||||
fn video_highres_schip_draw_schip_sprite() {}
|
||||
|
||||
|
||||
#[test]
|
||||
fn partial_eq_chip8computer() {
|
||||
let x = Chip8Computer::new();
|
||||
@@ -1543,9 +1543,15 @@ fn system_memory_load_program() {
|
||||
let mut m = Chip8SystemMemory::new();
|
||||
let mut program_to_load = vec![];
|
||||
let file_to_load = format!("{}/2-ibm-logo.ch8", TEST_ROM_ROOT);
|
||||
println!("Attempt to load {} from {}", file_to_load, std::env::current_dir().unwrap().display());
|
||||
println!(
|
||||
"Attempt to load {} from {}",
|
||||
file_to_load,
|
||||
std::env::current_dir().unwrap().display()
|
||||
);
|
||||
let mut file_to_load_from = File::open(file_to_load).expect("Unable to load sample rom");
|
||||
file_to_load_from.read_to_end(&mut program_to_load).expect("Unable to read sample rom");
|
||||
file_to_load_from
|
||||
.read_to_end(&mut program_to_load)
|
||||
.expect("Unable to read sample rom");
|
||||
m.load_program(program_to_load.clone().into());
|
||||
let expected_at_200 = program_to_load[0];
|
||||
assert_eq!(m.peek(0x200), expected_at_200);
|
||||
@@ -1591,7 +1597,7 @@ fn keys_test_manager() {
|
||||
#[test]
|
||||
fn status_of_manager() {
|
||||
let mut manager = Chip8ComputerManager::default();
|
||||
println!("MANAGER STATUS [{}]", manager.status_as_string());
|
||||
let expected_state = read_test_result("test_manager_status.asc");
|
||||
println!("MANAGER STATUS [{}]", manager.status_as_string());
|
||||
let expected_state = load_compressed_result("test_manager_status");
|
||||
assert_eq!(expected_state, manager.status_as_string());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user