blob: 745672a03c313e6d97488a6b529b7ea814941b1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
use crate::{serial_print,serial_println};
#[cfg(test)]
use crate::qemu::*;
/// # Testable trait
///
/// Trait for test functions
pub trait Testable {
fn run(&self) -> ();
}
impl<T> 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::<T>());
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);
}
|