mirror of
https://github.com/0xNikilite/oboromi.git
synced 2026-01-31 01:15:22 +01:00
Refactor test modules and update test integration
Moved test-related code from src/gui/tests.rs to src/tests/run.rs and created a new src/tests module. Updated imports and module structure to reflect this change. Removed old cpu_tests.rs and added manual_tests.rs to run all emulator feature tests using the new test runner.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use eframe::egui::{ScrollArea, CentralPanel};
|
||||
use crate::gui::run_tests;
|
||||
use crate::tests::run::run_tests;
|
||||
|
||||
/// GUI with a button to run tests and display results
|
||||
pub struct GUI {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
mod gui;
|
||||
mod tests;
|
||||
|
||||
pub use gui::GUI;
|
||||
pub use tests::run_tests;
|
||||
|
||||
@@ -2,3 +2,4 @@ pub mod cpu;
|
||||
pub mod memory;
|
||||
pub mod mmu;
|
||||
pub mod gui;
|
||||
pub mod tests;
|
||||
|
||||
3
src/tests/mod.rs
Normal file
3
src/tests/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod run;
|
||||
|
||||
pub use run::run_tests;
|
||||
@@ -1,44 +0,0 @@
|
||||
// tests/cpu_tests.rs
|
||||
|
||||
use oboromi::cpu::{CPU, Flags};
|
||||
use oboromi::memory::Memory;
|
||||
|
||||
#[test]
|
||||
fn memory_read_write() {
|
||||
let mut mem = Memory::new(1024);
|
||||
mem.write_byte(0, 0xAA);
|
||||
assert_eq!(mem.read_byte(0), 0xAA);
|
||||
mem.write_u32(4, 0xDEADBEEF);
|
||||
assert_eq!(mem.read_u32(4), 0xDEADBEEF);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cpu_nop_and_addi() {
|
||||
let mut cpu = CPU::new(64);
|
||||
// NOP
|
||||
cpu.memory.write_u32(0, 0xD503201F);
|
||||
cpu.step();
|
||||
assert_eq!(cpu.regs.pc, 4);
|
||||
|
||||
// ADDI X0, X0, #5
|
||||
cpu.reset();
|
||||
cpu.regs.x[0] = 10;
|
||||
cpu.memory.write_u32(0, 0x91001400);
|
||||
cpu.step();
|
||||
assert_eq!(cpu.regs.x[0], 15);
|
||||
assert!(!cpu.regs.flags.contains(Flags::ZERO));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cpu_branch_and_ret() {
|
||||
let mut cpu = CPU::new(64);
|
||||
cpu.memory.write_u32(0, 0x14000001); // B +1
|
||||
cpu.step();
|
||||
assert_eq!(cpu.regs.pc, 4);
|
||||
|
||||
cpu.reset();
|
||||
cpu.regs.x[30] = 0x20;
|
||||
cpu.memory.write_u32(0, 0xD65F03C0); // RET
|
||||
cpu.step();
|
||||
assert_eq!(cpu.regs.pc, 0x20);
|
||||
}
|
||||
9
tests/manual_tests.rs
Normal file
9
tests/manual_tests.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use oboromi::tests::run::run_tests;
|
||||
|
||||
#[test]
|
||||
fn test_run_all_emulator_features() {
|
||||
let results = run_tests();
|
||||
for line_content in results {
|
||||
println!("{}", line_content);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user