Skip to content

Commit

Permalink
remove test_utils feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrezot committed Dec 3, 2024
1 parent 3e90d83 commit e3027a7
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 17 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ name = "cosmian_findex"
path = "src/lib.rs"

[features]
default = []
bench = []
test-utils = []
redis-mem = ["redis"]

[dependencies]
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ mod memory;
mod ovec;
mod secret;
mod symmetric_key;
#[cfg(any(test, feature = "test-utils"))]
#[cfg(test)]
mod test;
mod value;

pub use address::Address;
pub use adt::{IndexADT, MemoryADT};
#[cfg(feature = "bench")]
pub use encoding::{Op, WORD_LENGTH};
#[cfg(any(feature = "bench", feature = "test-utils"))]
#[cfg(feature = "bench")]
pub use encoding::{dummy_decode, dummy_encode};
pub use error::Error;
pub use findex::Findex;
Expand All @@ -25,7 +25,7 @@ pub use memory::in_memory::InMemory;
#[cfg(feature = "redis-mem")]
pub use memory::redis::RedisMemory;
pub use secret::Secret;
#[cfg(feature = "test-utils")]
#[cfg(test)]
pub use test::memory::{
test_guarded_write_concurrent, test_single_write_and_read, test_wrong_guard,
};
Expand Down
7 changes: 1 addition & 6 deletions src/memory/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ impl<Address: Hash + Eq + Debug, Value: Clone + Eq + Debug> InMemory<Address, Va
}
}

#[cfg(any(test, feature = "bench"))]
pub fn clear(&self) {
self.inner.lock().expect("poisoned lock").clear();
}
Expand Down Expand Up @@ -79,30 +78,26 @@ impl<Address: Hash + Eq + Debug + Clone, Value: Clone + Eq + Debug> IntoIterator
.into_iter()
}
}

#[cfg(test)]
mod tests {

#[cfg(feature = "test-utils")]
use crate::{
memory::in_memory, test_guarded_write_concurrent, test_single_write_and_read,
test_wrong_guard,
};

#[cfg(feature = "test-utils")]
#[tokio::test]
async fn test_sequential_read_write() {
let memory = in_memory::InMemory::<[u8; 16], [u8; 16]>::default();
test_single_write_and_read(&memory, rand::random()).await;
}

#[cfg(feature = "test-utils")]
#[tokio::test]
async fn test_sequential_wrong_guard() {
let memory = in_memory::InMemory::<[u8; 16], [u8; 16]>::default();
test_wrong_guard(&memory, rand::random()).await;
}

#[cfg(feature = "test-utils")]
#[tokio::test]
async fn test_concurrent_read_write() {
let memory = in_memory::InMemory::<[u8; 16], [u8; 16]>::default();
Expand Down
1 change: 0 additions & 1 deletion src/memory/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ impl<const WORD_LENGTH: usize> MemoryADT
}
}

#[cfg(feature = "test-utils")]
#[cfg(test)]
mod tests {

Expand Down
5 changes: 0 additions & 5 deletions src/test/memory.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// ! This module defines tests any implementation of the MemoryADT interface
// must pass.
#[cfg(feature = "test-utils")]
use rand::{Rng, SeedableRng, rngs::StdRng};

#[cfg(feature = "test-utils")]
use crate::MemoryADT;

// TODO: should return a result type and proper errors

#[cfg(feature = "test-utils")]
pub async fn test_single_write_and_read<T>(memory: &T, seed: [u8; 32])
where
T: MemoryADT,
Expand Down Expand Up @@ -61,7 +58,6 @@ where
);
}

#[cfg(feature = "test-utils")]
pub async fn test_wrong_guard<T>(memory: &T, seed: [u8; 32])
where
T: MemoryADT,
Expand Down Expand Up @@ -116,7 +112,6 @@ where
);
}

#[cfg(feature = "test-utils")]
pub async fn test_guarded_write_concurrent<T>(memory: &T, seed: [u8; 32])
where
T: MemoryADT + Send + 'static + Clone,
Expand Down

0 comments on commit e3027a7

Please sign in to comment.