Skip to content

Commit

Permalink
Test defmt version range
Browse files Browse the repository at this point in the history
  • Loading branch information
korken89 committed Nov 11, 2021
1 parent 8a77f32 commit c241c9a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ x86-sync-pool = []
__trybuild = []
# Enable larger MPMC sizes.
mpmc_large = []
# This flag has no version guarantee, the `defmt` dependency can be updated in a patch release
defmt-impl = ["defmt"]

[target.'cfg(any(target_arch = "x86_64", target_arch = "x86"))'.dev-dependencies]
Expand Down Expand Up @@ -55,9 +56,5 @@ optional = true
version = "0.1"

[dependencies.defmt]
version = "0.2.1"
version = ">=0.2.0,<0.4"
optional = true

[dev-dependencies.defmt]
version = "0.2.1"
features = ["unstable-test"]
33 changes: 0 additions & 33 deletions src/defmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,3 @@ where
defmt::write!(fmt, "{=str}", self.as_str());
}
}

#[cfg(test)]
mod tests {
use crate::Vec;
use defmt::Format;

#[test]
/// Tests encoding Vec with defmt, asserting these types may be serialized
/// Note: the exact wire format is NOT checked since its an unstable implementation detail of an external crate.
/// based on https://github.com/knurling-rs/defmt/blob/697a8e807bd766a80ada2d57514a9da1232dbc9a/tests/encode.rs#L523
fn test_defmt_format_vec() {
let val: Vec<_, 8> = Vec::from_slice(b"abc").unwrap();

let mut f = defmt::InternalFormatter::new();
let g = defmt::Formatter { inner: &mut f };
val.format(g);
f.finalize();
}

/// Tests encoding String with defmt, asserting these types may be serialized
/// Note: the exact wire format is NOT checked since its an unstable implementation detail of an external crate.
/// based loosely on https://github.com/knurling-rs/defmt/blob/main/tests/encode.rs#L483
#[test]
fn test_defmt_format_str() {
let mut val: crate::String<32> = crate::String::new();
val.push_str("foo").unwrap();

let mut f = defmt::InternalFormatter::new();
let g = defmt::Formatter { inner: &mut f };
val.format(g);
f.finalize();
}
}

0 comments on commit c241c9a

Please sign in to comment.