-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add no_std compatibly test crate
Signed-off-by: Tom Dohrmann <[email protected]>
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "test" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//! This crate contains a very stripped down copy of the `test` crate. | ||
//! `test` usually requires full `std` support, but we need to use it from a | ||
//! `no_std` target. | ||
//! The `test` crate is implicitly used by the `#[test]` attribute. | ||
#![no_std] | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct TestDescAndFn { | ||
pub testfn: StaticTestFn, | ||
pub desc: TestDesc, | ||
} | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct StaticTestFn(pub fn()); | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct TestDesc { | ||
pub name: StaticTestName, | ||
pub ignore: bool, | ||
pub ignore_message: Option<&'static str>, | ||
pub source_file: &'static str, | ||
pub start_line: usize, | ||
pub start_col: usize, | ||
pub end_line: usize, | ||
pub end_col: usize, | ||
pub should_panic: ShouldPanic, | ||
pub compile_fail: bool, | ||
pub no_run: bool, | ||
pub test_type: TestType, | ||
} | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct StaticTestName(pub &'static str); | ||
|
||
#[derive(Clone, Copy)] | ||
pub enum TestType { | ||
UnitTest, | ||
} | ||
|
||
#[derive(PartialEq, Eq, Clone, Copy)] | ||
pub enum ShouldPanic { | ||
Yes, | ||
No, | ||
} | ||
|
||
pub fn assert_test_result(_: ()) {} |