Struct datadriven::TestCase

source ·
pub struct TestCase {
    pub directive: String,
    pub args: HashMap<String, Vec<String>>,
    pub input: String,
    /* private fields */
}
Expand description

A single test case within a file.

Fields§

§directive: String

The header for a test that denotes what kind of test is being run.

§args: HashMap<String, Vec<String>>

Any arguments that have been declared after the directive.

§input: String

The input to the test.

Implementations§

source§

impl TestCase

source

pub fn take_flag(&mut self, arg: &str) -> Result<bool, DataDrivenError>

Extract the given flag from the test case, removing it. Fails if there are any arguments for the value. Returns true if the flag was present.

source

pub fn take_arg<T>(&mut self, arg: &str) -> Result<T, DataDrivenError>
where T: FromStr, <T as FromStr>::Err: Error + Send + Sync + 'static,

Extract the given arg from the test case, removing it. Fails if there isn’t exactly one argument for the value.

source

pub fn try_take_arg<T>( &mut self, arg: &str ) -> Result<Option<T>, DataDrivenError>
where T: FromStr, <T as FromStr>::Err: Error + Send + Sync + 'static,

Extract the given arg from the test case, removing it if it exists.

source

pub fn take_args<T>(&mut self, arg: &str) -> Result<Vec<T>, DataDrivenError>
where T: FromStr, <T as FromStr>::Err: Error + Send + Sync + 'static,

Extract the given args from the test case, removing it. Returns an error if the argument was not present at all.

source

pub fn try_take_args<T>( &mut self, arg: &str ) -> Result<Option<Vec<T>>, DataDrivenError>
where T: FromStr, <T as FromStr>::Err: Error + Send + 'static,

Extract the given args from the test case, removing it.

source

pub fn expect_empty(&self) -> Result<(), DataDrivenError>

Trait Implementations§

source§

impl Clone for TestCase

source§

fn clone(&self) -> TestCase

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TestCase

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.