diff options
author | Joey Sacchini <joey@sacchini.net> | 2020-10-19 11:55:37 -0400 |
---|---|---|
committer | Joey Sacchini <joey@sacchini.net> | 2020-10-19 11:55:37 -0400 |
commit | 239a60fddab2694836f3117de429b9bf40256766 (patch) | |
tree | 007b927a3f3864639321cc988b0b0ad68f2c8662 /src/test_macros.rs | |
parent | a2c1bcbf82a3ed7d76d464abab708f5472cfaa3f (diff) | |
download | mcproto-rs-239a60fddab2694836f3117de429b9bf40256766.tar.gz mcproto-rs-239a60fddab2694836f3117de429b9bf40256766.tar.bz2 mcproto-rs-239a60fddab2694836f3117de429b9bf40256766.zip |
allow no_std with alloc
Diffstat (limited to 'src/test_macros.rs')
-rw-r--r-- | src/test_macros.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/test_macros.rs b/src/test_macros.rs index 254c3bb..ead3208 100644 --- a/src/test_macros.rs +++ b/src/test_macros.rs @@ -1,5 +1,7 @@ use crate::{SerializeResult, Serializer}; -#[cfg(test)] +use alloc::vec::Vec; + +#[cfg(all(test, feature = "std"))] #[macro_export] macro_rules! packet_test_cases { ($pnam: ident, $varnam: ident, $bodnam: ident, $testnam: ident, $benchnams: ident, $benchnamd: ident) => { @@ -70,13 +72,13 @@ macro_rules! packet_test_cases { }; } -#[cfg(test)] +#[cfg(all(test, feature = "std"))] #[derive(Clone, Debug, Default, PartialEq)] pub struct BenchSerializer { data: Vec<u8>, } -#[cfg(test)] +#[cfg(all(test, feature = "std"))] impl Serializer for BenchSerializer { fn serialize_bytes(&mut self, data: &[u8]) -> SerializeResult { self.data.extend_from_slice(data); @@ -84,7 +86,7 @@ impl Serializer for BenchSerializer { } } -#[cfg(test)] +#[cfg(all(test, feature = "std"))] impl BenchSerializer { pub fn reset(&mut self) { self.data.clear(); |