From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/proptest/src/path.rs | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 vendor/proptest/src/path.rs (limited to 'vendor/proptest/src/path.rs') diff --git a/vendor/proptest/src/path.rs b/vendor/proptest/src/path.rs new file mode 100644 index 000000000..76242817d --- /dev/null +++ b/vendor/proptest/src/path.rs @@ -0,0 +1,55 @@ +//! Strategies for generating [`PathBuf`] and related path types. +//! +//! [`PathParams`] in this module is used as the argument to the +//! [`Arbitrary`](crate::arbitrary::Arbitrary) implementation for [`PathBuf`]. + +use crate::{collection::SizeRange, string::StringParam}; + +/// Parameters for the [`Arbitrary`] implementation for [`PathBuf`]. +/// +/// By default, this generates paths with 0 to 8 components uniformly at random, each of which is a +/// default [`StringParam`]. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct PathParams { + /// The number of components in the path. + components: SizeRange, + /// The regular expression to generate individual components. + component_regex: StringParam, +} + +impl PathParams { + /// Gets the number of components in the path. + pub fn components(&self) -> SizeRange { + self.components.clone() + } + + /// Sets the number of components in the path. + pub fn with_components(mut self, components: impl Into) -> Self { + self.components = components.into(); + self + } + + /// Gets the regular expression to generate individual components. + pub fn component_regex(&self) -> StringParam { + self.component_regex + } + + /// Sets the regular expression to generate individual components. + pub fn with_component_regex( + mut self, + component_regex: impl Into, + ) -> Self { + self.component_regex = component_regex.into(); + self + } +} + +impl Default for PathParams { + fn default() -> Self { + Self { + components: (0..8).into(), + // This is the default regex for `any::()`. + component_regex: StringParam::default(), + } + } +} -- cgit v1.2.3