Skip to content

Commit

Permalink
fix: use a smaller CustomConfig for 32-bit tests (#84)
Browse files Browse the repository at this point in the history
This way, the custom-config tests from PR #80 can still be run on 32-bit
targets.

Fixes #82
  • Loading branch information
hawkw committed Sep 27, 2023
1 parent 049d40b commit 1445e83
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/tests/custom_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
#![cfg(not(loom))]

use crate::{Config, Slab};
use crate::{cfg::CfgPrivate, Config, Slab};

struct CustomConfig;

#[cfg(target_pointer_width = "64")]
impl Config for CustomConfig {
const INITIAL_PAGE_SIZE: usize = 32;
const MAX_PAGES: usize = 15;
const MAX_THREADS: usize = 256;
const RESERVED_BITS: usize = 24;
}

#[cfg(not(target_pointer_width = "64"))]
impl Config for CustomConfig32 {
const INITIAL_PAGE_SIZE: usize = 16;
const MAX_PAGES: usize = 7;
const MAX_THREADS: usize = 128;
const RESERVED_BITS: usize = 12;
}

// We should repeat actions several times to detect invalid lifecycle changes.
const ITERS: u64 = 5;

Expand All @@ -29,6 +39,8 @@ fn slab_eq(mut lhs: Slab<u64, impl Config>, mut rhs: Slab<u64, impl Config>) {
/// Initially, it revealed bugs in the `Slot::release_with()` implementation.
#[test]
fn insert_remove() {
eprintln!("bits={}; config={:#?}", usize::BITS, CustomConfig::debug());

let default_slab = Slab::<u64, _>::new();
let custom_slab = Slab::<u64, _>::new_with_config::<CustomConfig>();

Expand All @@ -47,6 +59,8 @@ fn insert_remove() {
/// Initially, it revealed bugs in the `Slot::get()` implementation.
#[test]
fn double_get() {
eprintln!("bits={}; config={:#?}", usize::BITS, CustomConfig::debug());

let default_slab = Slab::<u64, _>::new();
let custom_slab = Slab::<u64, _>::new_with_config::<CustomConfig>();

Expand Down

0 comments on commit 1445e83

Please sign in to comment.