Skip to content

Commit

Permalink
More unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Sep 11, 2024
1 parent dfa4327 commit a93c2b4
Show file tree
Hide file tree
Showing 4 changed files with 607 additions and 227 deletions.
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const MAGIC_TEXT_SIZE: usize = MAGIC_TEXT.len();
const MAGIC_VERSION_SIZE: usize = mem::size_of::<u16>();
const HEADER_SIZE: usize = MAGIC_TEXT_SIZE + MAGIC_VERSION_SIZE;

#[cfg(test)]
#[macro_use]
mod tests;

/// Error types.
pub mod error;

Expand All @@ -56,9 +60,6 @@ pub mod swmr;
/// An ordered write-ahead Log implementation.
pub mod unsync;

#[cfg(test)]
mod tests;

bitflags::bitflags! {
/// The flags of the entry.
struct Flags: u8 {
Expand Down
113 changes: 1 addition & 112 deletions src/swmr/wal/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,115 +6,4 @@ use super::*;

const MB: u32 = 1024 * 1024;

#[test]
fn test_construct_inmemory() {
construct_inmemory::<OrderWal<Ascend, Crc32>>();
}

#[test]
fn test_construct_map_anon() {
construct_map_anon::<OrderWal<Ascend, Crc32>>();
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_construct_map_file() {
construct_map_file::<OrderWal<Ascend, Crc32>>("swmr");
}

#[test]
fn test_construct_with_small_capacity_inmemory() {
construct_with_small_capacity_inmemory::<OrderWal<Ascend, Crc32>>();
}

#[test]
fn test_construct_with_small_capacity_map_anon() {
construct_with_small_capacity_map_anon::<OrderWal<Ascend, Crc32>>();
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_construct_with_small_capacity_map_file() {
construct_with_small_capacity_map_file::<OrderWal<Ascend, Crc32>>("swmr");
}

#[test]
fn test_insert_inmemory() {
insert(OrderWal::new(Builder::new().with_capacity(MB)).unwrap());
}

#[test]
fn test_insert_map_anon() {
insert(OrderWal::map_anon(Builder::new().with_capacity(MB)).unwrap());
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_insert_map_file() {
let dir = tempdir().unwrap();
insert(
OrderWal::map_mut(
dir.path().join("test_swmr_insert_map_file"),
Builder::new(),
OpenOptions::new()
.create_new(Some(MB))
.write(true)
.read(true),
)
.unwrap(),
);
}

#[test]
fn test_iter_inmemory() {
iter(OrderWal::new(Builder::new().with_capacity(MB)).unwrap());
}

#[test]
fn test_iter_map_anon() {
iter(OrderWal::map_anon(Builder::new().with_capacity(MB)).unwrap());
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_iter_map_file() {
let dir = tempdir().unwrap();
iter(
OrderWal::map_mut(
dir.path().join("test_swmr_iter_map_file"),
Builder::new(),
OpenOptions::new()
.create_new(Some(MB))
.write(true)
.read(true),
)
.unwrap(),
);
}

#[test]
fn test_range_inmemory() {
range(OrderWal::new(Builder::new().with_capacity(MB)).unwrap());
}

#[test]
fn test_range_map_anon() {
range(OrderWal::map_anon(Builder::new().with_capacity(MB)).unwrap());
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_range_map_file() {
let dir = tempdir().unwrap();
range(
OrderWal::map_mut(
dir.path().join("test_swmr_range_map_file"),
Builder::new(),
OpenOptions::new()
.create_new(Some(MB))
.write(true)
.read(true),
)
.unwrap(),
);
}
common_unittests!(swmr::OrderWal);
Loading

0 comments on commit a93c2b4

Please sign in to comment.