Skip to content

Commit

Permalink
Change cfg for test
Browse files Browse the repository at this point in the history
Now tests require alloc, previously it activated alloc automatically.
  • Loading branch information
alexkazik committed Mar 4, 2024
1 parent d6303d6 commit 0b40afe
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 14 deletions.
8 changes: 4 additions & 4 deletions lzss/src/dynamic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl LzssDyn {
///
/// The buffer, with `2 * (1 << EI)` bytes, is allocated on the heap.
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[cfg(any(test, feature = "alloc"))]
#[cfg(feature = "alloc")]
pub fn compress<R: Read, W: Write>(
&self,
mut reader: R,
Expand Down Expand Up @@ -129,7 +129,7 @@ impl LzssDyn {
///
/// The buffer, with `1 << EI` bytes, is allocated on the heap.
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[cfg(any(test, feature = "alloc"))]
#[cfg(feature = "alloc")]
pub fn decompress<R: Read, W: Write>(
&self,
mut reader: R,
Expand Down Expand Up @@ -186,10 +186,10 @@ impl core::fmt::Display for LzssDynError {

/// Implementation of [`Error`](std::error::Error) for [`LzssDynError`]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[cfg(any(test, feature = "std"))]
#[cfg(feature = "std")]
impl std::error::Error for LzssDynError {}

#[cfg(test)]
#[cfg(all(test, feature = "alloc"))]
mod tests {
use crate::dynamic::LzssDyn;
use crate::generic::Lzss;
Expand Down
2 changes: 1 addition & 1 deletion lzss/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<R: Display, W: Display> core::fmt::Display for LzssError<R, W> {

/// Implementation of [`Error`](std::error::Error) for [`LzssError`]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[cfg(any(test, feature = "std"))]
#[cfg(feature = "std")]
impl<R, W> std::error::Error for LzssError<R, W>
where
R: std::error::Error + 'static,
Expand Down
2 changes: 1 addition & 1 deletion lzss/src/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl<const EI: usize, const EJ: usize, const C: u8, const N: usize, const N2: us
};
}

#[cfg(test)]
#[cfg(all(test, feature = "alloc"))]
mod tests {
use crate::generic::Lzss;
use crate::slice::SliceReader;
Expand Down
10 changes: 5 additions & 5 deletions lzss/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(any(test, feature = "std")), no_std)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "safe", forbid(unsafe_code))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs)]
Expand Down Expand Up @@ -100,11 +100,11 @@ extern crate alloc;
pub use crate::dynamic::{LzssDyn, LzssDynError};
pub use crate::error::LzssError;
pub use crate::generic::Lzss;
#[cfg(any(test, feature = "std"))]
#[cfg(feature = "std")]
pub use crate::io_simple::{IOSimpleReader, IOSimpleWriter};
pub use crate::read_write::{Read, Write};
pub use crate::slice::{SliceReader, SliceWriteError, SliceWriter, SliceWriterExact};
#[cfg(any(test, feature = "alloc"))]
#[cfg(feature = "alloc")]
pub use crate::vec::VecWriter;
pub use crate::void::{
ResultLzssErrorVoidExt, ResultLzssErrorVoidReadExt, ResultLzssErrorVoidWriteExt,
Expand All @@ -114,12 +114,12 @@ mod bits;
mod dynamic;
mod error;
mod generic;
#[cfg(any(test, feature = "std"))]
#[cfg(feature = "std")]
mod io_simple;
mod macros;
mod read_write;
#[cfg_attr(feature = "safe", path = "slice_safe.rs")]
mod slice;
#[cfg(any(test, feature = "alloc"))]
#[cfg(feature = "alloc")]
mod vec;
mod void;
2 changes: 1 addition & 1 deletion lzss/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl core::fmt::Display for SliceWriteError {
}
}

#[cfg(any(test, feature = "std"))]
#[cfg(feature = "std")]
impl std::error::Error for SliceWriteError {}

/// Write into a slice.
Expand Down
2 changes: 1 addition & 1 deletion lzss/src/slice_safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl core::fmt::Display for SliceWriteError {
}
}

#[cfg(any(test, feature = "std"))]
#[cfg(feature = "std")]
impl std::error::Error for SliceWriteError {}

/// Write into a slice.
Expand Down
2 changes: 1 addition & 1 deletion lzss/src/vec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::read_write::Write;
#[cfg(not(any(test, feature = "std")))]
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use void::Void;

Expand Down
2 changes: 2 additions & 0 deletions lzss/tests/dynamic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "alloc")]

use common::{EXAMPLE_DATA, INIT_BYTE};
use lzss::{LzssDyn, ResultLzssErrorVoidExt, SliceReader, VecWriter};

Expand Down
2 changes: 2 additions & 0 deletions lzss/tests/generic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "alloc")]

use common::{EXAMPLE_DATA, INIT_BYTE};
use lzss::{Lzss, ResultLzssErrorVoidExt, SliceReader, VecWriter};

Expand Down

0 comments on commit 0b40afe

Please sign in to comment.