From c1f457814db377507c02d391a52ec697a6f8cf69 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Thu, 30 Mar 2023 08:53:10 -0500 Subject: [PATCH] disassembler: 100% line coverage --- src/cpu/disassembler.rs | 2 +- tests/integration.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/cpu/disassembler.rs b/src/cpu/disassembler.rs index 3babd28..39b325f 100644 --- a/src/cpu/disassembler.rs +++ b/src/cpu/disassembler.rs @@ -6,7 +6,7 @@ use owo_colors::{OwoColorize, Style}; use std::fmt::Display; #[allow(non_camel_case_types, non_snake_case, missing_docs)] -#[derive(Clone, Copy, InstructionSet)] +#[derive(Clone, Copy, Debug, InstructionSet, PartialEq, Eq)] /// Implements a Disassembler using imperative_rs pub enum Insn { /// | 00e0 | Clear screen memory to 0s diff --git a/tests/integration.rs b/tests/integration.rs index 8b09d28..c1cb003 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -189,6 +189,22 @@ mod cpu { } } +mod dis { + use chirp::cpu::disassembler::Insn; + use imperative_rs::InstructionSet; + + #[test] + fn clone() { + let opcode = Insn::decode(&[0xeF, 0xa1]).unwrap().1; // random valid opcode + let clone = opcode.clone(); + assert_eq!(opcode, clone); + } + #[test] + fn debug() { + println!("{:?}", Insn::decode(b"AA")) // "sne #41, v1" + } +} + #[test] fn error() { let error = chirp::error::Error::MissingRegion { region: Screen };