Skip to content

Commit

Permalink
Add missing hex feature gate
Browse files Browse the repository at this point in the history
`hex` was previously enabled by `alloc`, now it is optional add the
missing feature gate to tests.
  • Loading branch information
jamillambert committed Feb 14, 2025
1 parent fce0cf1 commit e7c6564
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions hashes/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ mod tests {
}

#[cfg(bench)]
#[cfg(feature = "hex")]
mod benches {
use test::Bencher;

Expand Down
1 change: 1 addition & 0 deletions hashes/src/hash160/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl crate::HashEngine for HashEngine {
mod tests {
#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn test() {
use alloc::string::ToString;

Expand Down
1 change: 1 addition & 0 deletions hashes/src/hkdf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ where

#[cfg(test)]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
mod tests {
use hex::prelude::{DisplayHex, FromHex};

Expand Down
1 change: 1 addition & 0 deletions hashes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ mod tests {

#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn newtype_fmt_roundtrip() {
use alloc::format;

Expand Down
1 change: 1 addition & 0 deletions hashes/src/ripemd160/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn test() {
use alloc::string::ToString;

Expand Down
1 change: 1 addition & 0 deletions hashes/src/sha1/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn test() {
use alloc::string::ToString;

Expand Down
2 changes: 2 additions & 0 deletions hashes/src/sha256/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{sha256, HashEngine};

#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn test() {
use alloc::string::ToString;

Expand Down Expand Up @@ -70,6 +71,7 @@ fn test() {

#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn fmt_roundtrips() {
use alloc::format;

Expand Down
2 changes: 2 additions & 0 deletions hashes/src/sha256d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mod tests {

#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn test() {
use alloc::string::ToString;

Expand Down Expand Up @@ -98,6 +99,7 @@ mod tests {

#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn fmt_roundtrips() {
use alloc::format;

Expand Down
4 changes: 4 additions & 0 deletions hashes/src/sha256t/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ mod tests {

// The digest created by sha256 hashing `&[0]` starting with `TEST_MIDSTATE`.
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
const HASH_ZERO_BACKWARD: &str =
"29589d5122ec666ab5b4695070b6debc63881a4f85d88d93ddc90078038213ed";
// And the same thing, forward.
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
const HASH_ZERO_FORWARD: &str =
"ed1382037800c9dd938dd8854f1a8863bcdeb6705069b4b56a66ec22519d5829";

Expand All @@ -198,10 +200,12 @@ mod tests {

// We support manually implementing `Tag` and creating a tagged hash from it.
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
pub type TestHash = sha256t::Hash<TestHashTag>;

#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn manually_created_sha256t_hash_type() {
use alloc::string::ToString;

Expand Down
1 change: 1 addition & 0 deletions hashes/src/sha384/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl crate::HashEngine for HashEngine {
mod tests {
#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn test() {
use alloc::string::ToString;

Expand Down
1 change: 1 addition & 0 deletions hashes/src/sha512/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn test() {
use alloc::string::ToString;

Expand Down
1 change: 1 addition & 0 deletions hashes/src/sha512_256/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl crate::HashEngine for HashEngine {
mod tests {
#[test]
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
fn test() {
use alloc::string::ToString;

Expand Down

0 comments on commit e7c6564

Please sign in to comment.