diff --git a/minicbor-tests/Cargo.toml b/minicbor-tests/Cargo.toml index 50e269a..96d562f 100644 --- a/minicbor-tests/Cargo.toml +++ b/minicbor-tests/Cargo.toml @@ -11,9 +11,11 @@ description = "minicbor test suite" alloc = ["minicbor/alloc"] std = ["alloc", "minicbor/std", "minicbor/derive"] derive = ["alloc", "minicbor/derive"] +heapless = ["dep:heapless", "minicbor/heapless"] [dependencies] arbitrary = { version = "1.3.2", features = ["derive"] } +heapless = { version = "0.8.0", default-features = false, optional = true } minicbor = { path = "../minicbor", features = ["half"] } [dev-dependencies] diff --git a/minicbor-tests/tests/encoding.rs b/minicbor-tests/tests/encoding.rs index aca86fc..69c5253 100644 --- a/minicbor-tests/tests/encoding.rs +++ b/minicbor-tests/tests/encoding.rs @@ -259,3 +259,11 @@ fn regular_enum() { assert!(d.skip().unwrap_err().is_end_of_input()) } +#[cfg(feature = "heapless")] +#[test] +fn heapless() { + let original = heapless::String::<20>::try_from("BOR").unwrap(); + let bytes = minicbor::to_vec(&original).unwrap(); + assert_eq!(&b"cBOR"[..], &bytes[..]); + assert_eq!(original, minicbor::decode::>(&bytes).unwrap()); +}