Added macro to get new thread easily and started writing test
This commit is contained in:
parent
0f339dd936
commit
8bf7a452f3
@ -103,10 +103,26 @@ fn start_thread_execution() {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
use super::Thread;
|
use super::{Thread, ThreadContext};
|
||||||
|
|
||||||
fn get_new_thread() -> Thread {
|
macro_rules! get_new_thread {
|
||||||
Thread::new("test_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!();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user