From 0f339dd936ab1aed8f36cda51acfd2af520a775d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Thu, 9 Mar 2023 12:44:03 +0100 Subject: [PATCH] Changed constructor to allow any string slice as parameter + started writing unit tests --- src/kernel/thread.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/kernel/thread.rs b/src/kernel/thread.rs index 326bb9c..1b8b41d 100644 --- a/src/kernel/thread.rs +++ b/src/kernel/thread.rs @@ -23,9 +23,9 @@ pub struct Thread { impl Thread { /// Thread constructor - pub fn new(name: String) -> Self { + pub fn new(name: &str) -> Self { Self { - name, + name: String::from(name), process: None, // simulation_context: UContextT::new(), thread_context: ThreadContext { @@ -98,4 +98,15 @@ impl Drop for Thread { fn start_thread_execution() { +} + +#[cfg(test)] +mod test { + + use super::Thread; + + fn get_new_thread() -> Thread { + Thread::new("test_thread") + } + } \ No newline at end of file