From 60b52a29c16a58ee05d98066c847956244711bff Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Thu, 12 Dec 2024 21:08:19 +0200 Subject: [PATCH] add unit test for clear screen --- src/emulator.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/emulator.rs b/src/emulator.rs index 2d1e405..e3cad96 100644 --- a/src/emulator.rs +++ b/src/emulator.rs @@ -515,4 +515,19 @@ mod tests { // Assert assert_eq!(emulator.memory[0x200..0x200 + 132], rom_file_data) } + + #[test] + fn test_execute_clear_screen_instruction() { + // Setup + let mut emulator = Emulator::new(TerminalDisplay::new(), TerminalSound, NoInput); + for i in 10..30 { + emulator.display_data[i] = true; + } + + // Test + emulator.execute_instruction(Instruction::new([0x00, 0xE0])).expect("Failed to execute"); + + // Assert + assert!(emulator.display_data.iter().all(|&pixel| { pixel == false})) + } }