1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-05-10 17:46:15 +02:00
youki/tests/contest/test_framework/src/test.rs
Toru Komatsu 464344923f
Name the test tools `contest` (#2486)
* Name the test tools `contest`

Signed-off-by: utam0k <k0ma@utam0k.jp>

* Address the feedbacks

Signed-off-by: utam0k <k0ma@utam0k.jp>

* Fix a build error

Signed-off-by: utam0k <k0ma@utam0k.jp>

* Fix a workflow

Signed-off-by: utam0k <k0ma@utam0k.jp>

* Address the feedbacks

Signed-off-by: utam0k <k0ma@utam0k.jp>

---------

Signed-off-by: utam0k <k0ma@utam0k.jp>
2024-01-12 14:28:47 +05:30

31 lines
673 B
Rust

//! Contains definition for a simple and commonly usable test structure
use crate::testable::{TestResult, Testable};
// type alias for the test function
type TestFn = dyn Sync + Send + Fn() -> TestResult;
/// Basic Template structure for a test
pub struct Test {
/// name of the test
name: &'static str,
/// Actual test function
test_fn: Box<TestFn>,
}
impl Test {
/// create new test
pub fn new(name: &'static str, test_fn: Box<TestFn>) -> Self {
Test { name, test_fn }
}
}
impl Testable for Test {
fn get_name(&self) -> &'static str {
self.name
}
fn run(&self) -> TestResult {
(self.test_fn)()
}
}