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 bab6fcf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 40 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [v0.7.8] - 2021-11-11

### Added

- A span of `defmt` versions is now supported (`0.2` and `0.3`)

## [v0.7.7] - 2021-09-22

### Fixed
Expand Down Expand Up @@ -417,7 +423,8 @@ architecture.

- Initial release

[Unreleased]: https://github.com/japaric/heapless/compare/v0.7.7...HEAD
[Unreleased]: https://github.com/japaric/heapless/compare/v0.7.8...HEAD
[v0.7.9]: https://github.com/japaric/heapless/compare/v0.7.7...v0.7.8
[v0.7.7]: https://github.com/japaric/heapless/compare/v0.7.6...v0.7.7
[v0.7.6]: https://github.com/japaric/heapless/compare/v0.7.5...v0.7.6
[v0.7.5]: https://github.com/japaric/heapless/compare/v0.7.4...v0.7.5
Expand Down
9 changes: 3 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["static", "no-heap"]
license = "MIT OR Apache-2.0"
name = "heapless"
repository = "https://github.com/japaric/heapless"
version = "0.7.7"
version = "0.7.8"

[features]
default = ["cas"]
Expand All @@ -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 bab6fcf

Please sign in to comment.