From e827f664f9d2104f1785774c300e91753c370576 Mon Sep 17 00:00:00 2001 From: victor <victor@xirion.net> Date: Tue, 4 Oct 2022 15:37:47 +0200 Subject: [PATCH] a bit more docs --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 952dfb1..db02a49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1031,7 +1031,7 @@ dependencies = [ [[package]] name = "tudelft-nes-test" -version = "1.1.3" +version = "1.1.4" dependencies = [ "bitflags", "log", diff --git a/Cargo.toml b/Cargo.toml index 5eed20b..de43234 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tudelft-nes-test" -version = "1.1.3" +version = "1.1.4" edition = "2021" authors = [ "Victor Roest <victor@xirion.net>", diff --git a/src/lib.rs b/src/lib.rs index d430c2e..a1e4f91 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,8 +15,16 @@ use crate::nestest::nestest_status_code; /// Implement this trait to run our test on our CPU via the [`run_tests`] function. pub trait TestableCpu: Cpu + Sized + 'static { + /// This function is used by the test suite to get a handle on your CPU + /// `rom` is a rom file in INES format. fn get_cpu(rom: &[u8]) -> Result<Self, Box<dyn Error>>; + + /// [`set_program_counter`] is used to set the program counter of the cpu to a specific position + /// this is needed by some tests. fn set_program_counter(&mut self, value: u16); + + /// [`memory_read`] is used to test the succesfulness of tests by seeing if the CPU has expected values + /// at certain memory locations, it simply takes an address and should return the byte of data at that memory location fn memory_read(&self, address: u16) -> u8; } @@ -71,9 +79,6 @@ pub fn run_tests<T: TestableCpu>(selector: TestSelector) -> Result<(), String> { if selector.contains(TestSelector::NESTEST) { nestest::<T>()?; } - - - Ok(()) } -- GitLab