use crate::{serial_print,serial_println}; #[cfg(test)] use crate::qemu::*; /// # Testable trait /// /// Trait for test functions pub trait Testable { fn run(&self) -> (); } impl Testable for T where T: Fn(), { /// # Default run /// /// Run each test and print results to output fn run(&self) { serial_print!("{}...\t", core::any::type_name::()); self(); serial_println!("[ok]"); } } /// # Run tests /// /// Run each of the tests #[cfg(test)] pub fn test_runner(tests: &[&dyn Testable]) { serial_println!("Running {} tests", tests.len()); for test in tests { test.run(); } exit_qemu(QemuExitCode::Success); } /// # Trivial test /// /// This test ought to succeed no matter what #[test_case] fn trivial_assertion() { assert_eq!(1, 1); }