defmt
defmt copied to clipboard
Allow std-level unit testing of the formatting itself
In my crate, I have many enums declared with #[derive(defmt::Format)].
I would like to check that the format output is what I expect without requiring real hardware or an emulator. defmt has internal encoding tests in the https://github.com/knurling-rs/defmt/blob/main/defmt/tests/encode.rs , but the write_format fn uses private function _format_data to do some magical formatting. Is there a way to have a well defined API I can use in the regular std environment to check the format trait output? Perhaps introduce some test helper that simply returns a String?
https://github.com/gibbz00/redefmt/blob/4750be6195578456c75667487d4d446ba375f932/crates/pretty_printer/src/lib.rs#L333-L352 👀
WIP though, hope to share more very soon.
I think this use case ~~is~~ will be handled by https://github.com/knurling-rs/defmt/issues/969?