Added macro to get new thread easily and started writing test

This commit is contained in:
François Autin 2023-03-09 13:07:50 +01:00
parent eeac26aba6
commit 71ccd0c16e
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C

View File

@ -103,10 +103,26 @@ fn start_thread_execution() {
#[cfg(test)]
mod test {
use super::Thread;
use super::{Thread, ThreadContext};
fn get_new_thread() -> Thread {
Thread::new("test_thread")
macro_rules! get_new_thread {
() => { Thread::new("test_thread") };
($a:literal) => {
Thread::new(&$a.to_string())
};
}
#[test]
fn test_macro() {
let t = get_new_thread!("hello");
assert_eq!(t.get_name(), "hello");
let t = get_new_thread!(1);
assert_eq!(t.get_name(), "1");
}
#[test]
fn check_init() {
let t = get_new_thread!();
}
}