-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from Sh3Rm4n/test-defmt-test
Test defmt-test
- Loading branch information
Showing
5 changed files
with
53 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
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 @@ | ||
0.000000 INFO (1/3) running `assert_true`... | ||
0.000000 INFO (2/3) running `assert_imported_max`... | ||
0.000000 INFO (3/3) running `assert_eq`... | ||
0.000000 ERROR panicked at 'assertion failed: `(left == right)`: TODO: write actual tests' | ||
left: `24` | ||
right: `42` |
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 @@ | ||
0.000000 INFO (1/3) running `assert_true`... | ||
0.000000 INFO (2/3) running `assert_imported_max`... | ||
0.000000 INFO (3/3) running `assert_eq`... | ||
0.000000 ERROR panicked at 'assertion failed: `(left == right)`: TODO: write actual tests' | ||
left: `24` | ||
right: `42` |
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,35 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
use defmt_semihosting as _; // global logger | ||
use core::u8::MAX; | ||
|
||
#[defmt_test::tests] | ||
mod tests { | ||
use super::MAX; | ||
#[test] | ||
fn assert_true() { | ||
defmt::assert!(true) | ||
} | ||
|
||
#[test] | ||
fn assert_imported_max() { | ||
defmt::assert_eq!(255, MAX) | ||
} | ||
|
||
#[test] | ||
fn assert_eq() { | ||
defmt::assert_eq!(24, 42, "TODO: write actual tests") | ||
} | ||
} | ||
|
||
// like `panic-semihosting` but doesn't print to stdout (that would corrupt the defmt stream) | ||
#[cfg(target_os = "none")] | ||
#[panic_handler] | ||
fn panic(_: &core::panic::PanicInfo) -> ! { | ||
use cortex_m_semihosting::debug; | ||
|
||
loop { | ||
debug::exit(debug::EXIT_SUCCESS) | ||
} | ||
} |
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