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
impl TestCase
sourcepub fn take_flag(&mut self, arg: &str) -> Result<bool, DataDrivenError>
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.
sourcepub fn take_arg<T>(&mut self, arg: &str) -> Result<T, DataDrivenError>
pub fn take_arg<T>(&mut self, arg: &str) -> Result<T, DataDrivenError>
Extract the given arg from the test case, removing it. Fails if there isn’t exactly one argument for the value.
sourcepub fn try_take_arg<T>(
&mut self,
arg: &str,
) -> Result<Option<T>, DataDrivenError>
pub fn try_take_arg<T>( &mut self, arg: &str, ) -> Result<Option<T>, DataDrivenError>
Extract the given arg from the test case, removing it if it exists.
sourcepub fn take_args<T>(&mut self, arg: &str) -> Result<Vec<T>, DataDrivenError>
pub fn take_args<T>(&mut self, arg: &str) -> Result<Vec<T>, DataDrivenError>
Extract the given args from the test case, removing it. Returns an error if the argument was not present at all.
sourcepub fn try_take_args<T>(
&mut self,
arg: &str,
) -> Result<Option<Vec<T>>, DataDrivenError>
pub fn try_take_args<T>( &mut self, arg: &str, ) -> Result<Option<Vec<T>>, DataDrivenError>
Extract the given args from the test case, removing it.
pub fn expect_empty(&self) -> Result<(), DataDrivenError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TestCase
impl RefUnwindSafe for TestCase
impl Send for TestCase
impl Sync for TestCase
impl Unpin for TestCase
impl UnwindSafe for TestCase
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)