Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/iddqd-test-utils/src/naive_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ impl NaiveMap {
pub fn clear(&mut self) {
self.items.clear();
}

pub fn extend<I: IntoIterator<Item = TestItem>>(&mut self, iter: I) {
// Mirrors `Extend` on the real maps: each item overwrites any
// pre-existing duplicates under the active uniqueness constraint.
for item in iter {
self.insert_overwrite(item);
}
}
}

/// Which keys to check uniqueness against.
Expand Down
15 changes: 12 additions & 3 deletions crates/iddqd/tests/integration/bi_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ enum Operation {
RetainValueContains(char, bool),
#[weight(2)]
RetainModulo(#[strategy(0..3_u8)] u8, #[strategy(1..4_u8)] u8, bool),
#[weight(2)]
Extend(
#[strategy(prop::collection::vec(any::<TestItem>(), 0..16))]
Vec<TestItem>,
),
Clear,
// `additional` is kept modest so that reservations frequently
// exceed the current `growth_left` and so trigger hashbrown's
Expand Down Expand Up @@ -271,9 +276,8 @@ impl Operation {
| Operation::Remove1(_)
| Operation::Remove2(_)
| Operation::RetainValueContains(_, _)
| Operation::RetainModulo(_, _, _) => {
CompactnessChange::NoLongerCompact
}
| Operation::RetainModulo(_, _, _)
| Operation::Extend(_) => CompactnessChange::NoLongerCompact,
// Clear always makes the map compact (empty).
Operation::Clear => CompactnessChange::BecomesCompact,
}
Expand Down Expand Up @@ -381,6 +385,11 @@ fn proptest_ops(
});
map.validate(compactness).expect("map should be valid");
}
Operation::Extend(items) => {
map.extend(items.clone());
naive_map.extend(items);
map.validate(compactness).expect("map should be valid");
}
Operation::Reserve(additional) => {
map.reserve(additional);
// `reserve` has no observable effect beyond capacity; the
Expand Down
15 changes: 12 additions & 3 deletions crates/iddqd/tests/integration/id_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ enum Operation {
RetainValueContains(char, bool),
#[weight(2)]
RetainModulo(#[strategy(0..3_u8)] u8, #[strategy(1..4_u8)] u8, bool),
#[weight(2)]
Extend(
#[strategy(prop::collection::vec(any::<TestItem>(), 0..16))]
Vec<TestItem>,
),
Clear,
// `additional` is kept modest so that reservations frequently
// exceed the current `growth_left` and so trigger hashbrown's
Expand Down Expand Up @@ -222,9 +227,8 @@ impl Operation {
Operation::InsertOverwrite(_)
| Operation::Remove(_)
| Operation::RetainValueContains(_, _)
| Operation::RetainModulo(_, _, _) => {
CompactnessChange::NoLongerCompact
}
| Operation::RetainModulo(_, _, _)
| Operation::Extend(_) => CompactnessChange::NoLongerCompact,
// Clear always makes the map compact (empty).
Operation::Clear => CompactnessChange::BecomesCompact,
}
Expand Down Expand Up @@ -310,6 +314,11 @@ fn proptest_ops(
});
map.validate(compactness).expect("map should be valid");
}
Operation::Extend(items) => {
map.extend(items.clone());
naive_map.extend(items);
map.validate(compactness).expect("map should be valid");
}
Operation::Clear => {
map.clear();
naive_map.clear();
Expand Down
16 changes: 13 additions & 3 deletions crates/iddqd/tests/integration/id_ord_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ enum Operation {
RetainValueContains(char, bool),
#[weight(2)]
RetainModulo(#[strategy(0..3_u8)] u8, #[strategy(1..4_u8)] u8, bool),
#[weight(2)]
Extend(
#[strategy(prop::collection::vec(any::<TestItem>(), 0..16))]
Vec<TestItem>,
),
// clear is set to a lower weight since it makes the map empty.
Clear,
}
Expand All @@ -261,9 +266,8 @@ impl Operation {
| Operation::PopFirst
| Operation::PopLast
| Operation::RetainValueContains(_, _)
| Operation::RetainModulo(_, _, _) => {
CompactnessChange::NoLongerCompact
}
| Operation::RetainModulo(_, _, _)
| Operation::Extend(_) => CompactnessChange::NoLongerCompact,
// Clear always makes the map compact (empty).
Operation::Clear => CompactnessChange::BecomesCompact,
}
Expand Down Expand Up @@ -428,6 +432,12 @@ fn proptest_ops(
map.validate(compactness, ValidateChaos::No)
.expect("map should be valid");
}
Operation::Extend(items) => {
map.extend(items.clone());
naive_map.extend(items);
map.validate(compactness, ValidateChaos::No)
.expect("map should be valid");
}
Operation::Clear => {
map.clear();
naive_map.clear();
Expand Down
15 changes: 12 additions & 3 deletions crates/iddqd/tests/integration/tri_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ enum Operation {
RetainValueContains(char, bool),
#[weight(2)]
RetainModulo(#[strategy(0..3_u8)] u8, #[strategy(1..4_u8)] u8, bool),
#[weight(2)]
Extend(
#[strategy(prop::collection::vec(any::<TestItem>(), 0..16))]
Vec<TestItem>,
),
Clear,
// `additional` is kept modest so that reservations frequently
// exceed the current `growth_left` and so trigger hashbrown's
Expand Down Expand Up @@ -302,9 +307,8 @@ impl Operation {
| Operation::Remove2(_)
| Operation::Remove3(_)
| Operation::RetainValueContains(_, _)
| Operation::RetainModulo(_, _, _) => {
CompactnessChange::NoLongerCompact
}
| Operation::RetainModulo(_, _, _)
| Operation::Extend(_) => CompactnessChange::NoLongerCompact,
// Clear always makes the map compact (empty).
Operation::Clear => CompactnessChange::BecomesCompact,
}
Expand Down Expand Up @@ -425,6 +429,11 @@ fn proptest_ops(
});
map.validate(compactness).expect("map should be valid");
}
Operation::Extend(items) => {
map.extend(items.clone());
naive_map.extend(items);
map.validate(compactness).expect("map should be valid");
}
Operation::Clear => {
map.clear();
naive_map.clear();
Expand Down
Loading