mirror of
https://github.com/containers/youki
synced 2024-05-10 17:46:15 +02:00
464344923f
* 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>
31 lines
673 B
Rust
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)()
|
|
}
|
|
}
|