Struct proptest::char::CharStrategy[][src]

#[must_use = "strategies do nothing unless used"]pub struct CharStrategy<'a> { /* fields omitted */ }

Strategy for generating chars.

Character selection is more sophisticated than integer selection. Naïve selection (particularly in the larger context of generating strings) would result in starting inputs like ꂡ螧轎ቶᢹ糦狥芹ᘆ㶏曊ᒀ踔虙ჲ and "simplified" inputs consisting mostly of control characters. It also has difficulty locating edge cases, since the vast majority of code points (such as the enormous CJK regions) don't cause problems for anything with even basic Unicode support.

Instead, character selection is always based on explicit ranges, and is designed to bias to specifically chosen characters and character ranges to produce inputs that are both more useful and easier for humans to understand. There are also hard-wired simplification targets based on ASCII instead of simply simplifying towards NUL to avoid problematic inputs being reduced to a bunch of NUL characters.

Shrinking never crosses ranges. If you have a complex range like [A-Za-z] and the starting point x is chosen, it will not shrink to the first A-Z group, but rather simply to a.

The usual way to get instances of this class is with the module-level ANY constant or range function. Directly constructing a CharStrategy is only necessary for complex ranges or to override the default biases.

Implementations

impl<'a> CharStrategy<'a>[src]

pub fn new(
    special: Cow<'a, [char]>,
    preferred: Cow<'a, [RangeInclusive<char>]>,
    ranges: Cow<'a, [RangeInclusive<char>]>
) -> Self
[src]

Construct a new CharStrategy with the parameters it will pass to the function underlying select_char().

All arguments as per select_char().

pub fn new_borrowed(
    special: &'a [char],
    preferred: &'a [RangeInclusive<char>],
    ranges: &'a [RangeInclusive<char>]
) -> Self
[src]

Same as CharStrategy::new() but using Cow::Borrowed for all parts.

Trait Implementations

impl<'a> Clone for CharStrategy<'a>[src]

impl<'a> Debug for CharStrategy<'a>[src]

impl<'a> Strategy for CharStrategy<'a>[src]

type Tree = CharValueTree

The value tree generated by this Strategy.

type Value = char

The type of value used by functions under test generated by this Strategy. Read more

Auto Trait Implementations

impl<'a> Send for CharStrategy<'a>[src]

impl<'a> Sync for CharStrategy<'a>[src]

impl<'a> Unpin for CharStrategy<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,