1#![no_std]
4#![allow(clippy::needless_doctest_main)]
5#![cfg_attr(not(doctest), doc = include_str!("../README.md"))]
6
7mod fmt;
8
9pub use embedded_test_macros::tests;
10
11#[cfg(feature = "panic-handler")]
12#[panic_handler]
13fn panic(info: &core::panic::PanicInfo) -> ! {
14 error!("====================== PANIC ======================");
15
16 #[cfg(not(feature = "defmt"))]
17 error!("{}", info);
18
19 #[cfg(feature = "defmt")]
20 error!("{}", defmt::Display2Format(info));
21
22 semihosting::process::abort()
23}
24
25#[doc(hidden)]
28pub mod export;
29
30mod sealed {
31 pub trait Sealed {}
32 impl Sealed for () {}
33 impl<T, E> Sealed for Result<T, E> {}
34}
35
36#[cfg(feature = "defmt")]
42pub trait TestOutcome: defmt::Format + sealed::Sealed {
43 fn is_success(&self) -> bool;
44}
45
46#[cfg(feature = "log")]
52pub trait TestOutcome: core::fmt::Debug + sealed::Sealed {
53 fn is_success(&self) -> bool;
54}
55
56#[cfg(all(not(feature = "log"), not(feature = "defmt")))]
62pub trait TestOutcome: sealed::Sealed {
63 fn is_success(&self) -> bool;
64}
65
66impl TestOutcome for () {
67 fn is_success(&self) -> bool {
68 true
69 }
70}
71
72#[cfg(feature = "log")]
73impl<T: core::fmt::Debug, E: core::fmt::Debug> TestOutcome for Result<T, E> {
74 fn is_success(&self) -> bool {
75 self.is_ok()
76 }
77}
78
79#[cfg(feature = "defmt")]
80impl<T: defmt::Format, E: defmt::Format> TestOutcome for Result<T, E> {
81 fn is_success(&self) -> bool {
82 self.is_ok()
83 }
84}
85
86#[cfg(all(not(feature = "log"), not(feature = "defmt")))]
87impl<T, E> TestOutcome for Result<T, E> {
88 fn is_success(&self) -> bool {
89 self.is_ok()
90 }
91}