Skip to content

Commit

Permalink
test(service): fix ports::ShortRanges generation
Browse files Browse the repository at this point in the history
  • Loading branch information
k9withabone committed Apr 23, 2024
1 parent 821d852 commit ae3f571
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/service/ports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,16 +1031,21 @@ pub(super) mod tests {
}
}

prop_compose! {
fn short_ranges()(range in range())(
range in Just(range),
offset in ..u16::MAX - range.end.unwrap_or(range.start)
) -> ShortRanges {
ShortRanges {
fn short_ranges() -> impl Strategy<Value = ShortRanges> {
range()
.prop_flat_map(|range| {
let range_end = range.end.unwrap_or(range.start);
let offset = if range_end == u16::MAX {
Just(0).boxed()
} else {
(..u16::MAX - range_end).boxed()
};
(Just(range), offset)
})
.prop_map(|(range, offset)| ShortRanges {
host: (offset != 0).then(|| range + offset),
container: range,
}
}
})
}

pub(in super::super) fn range() -> impl Strategy<Value = Range> {
Expand Down

0 comments on commit ae3f571

Please sign in to comment.