pub struct Test<'a> {
pub result: bool,
pub number: Option<i32>,
pub description: Option<&'a str>,
pub directive: Option<Directive<'a>>,
pub yaml: Vec<&'a str>,
}Expand description
A Test declaring the result of some test-case.
Fields§
§result: boolResult of the test.
number: Option<i32>Number of the test.
description: Option<&'a str>Description of the test.
directive: Option<Directive<'a>>Directive detailing this tests meta-execution.
yaml: Vec<&'a str>List of YAML lines detailing the test execution.
Implementations§
Source§impl<'a> Test<'a>
impl<'a> Test<'a>
Sourcepub fn parse_from_str(content: &'a str) -> Result<Self>
pub fn parse_from_str(content: &'a str) -> Result<Self>
Parse Test from a &str.
§Examples
Parsing a TAP test may look like this:
use tapconsooomer::Test;
let content = "not ok 1 - foo()";
let test = Test::parse_from_str(content).expect("Parser error");
assert_eq!(test.result, false);
assert_eq!(test.number, Some(1));
assert_eq!(test.description, Some("foo()"));
assert_eq!(test.directive.is_none(), true);
assert_eq!(test.yaml.len(), 0);Note, many attributes of a TAP test are optional. A minimal TAP test may look like this:
use tapconsooomer::Test;
let content = "ok";
let test = Test::parse_from_str(content).expect("Parser error");
assert_eq!(test.result, true);
assert_eq!(test.number, None);
assert_eq!(test.description, None);
assert_eq!(test.directive.is_none(), true);
assert_eq!(test.yaml.len(), 0);TAP tests may also optionally contain a YAML block. While no parsing of actual YAML syntax is performed, the
parser captures each line inside the YAML block in a Vec:
use tapconsooomer::Test;
let content = concat!(
"not ok 2 - bar()\n",
" ---\n",
" message: invalid input\n",
" status: failed\n",
" ...\n",
);
let test = Test::parse_from_str(content).expect("Parser error");
assert_eq!(test.result, false);
assert_eq!(test.number, Some(2));
assert_eq!(test.description, Some("bar()"));
assert_eq!(test.directive.is_none(), true);
assert_eq!(test.yaml.len(), 2);
assert_eq!(test.yaml, ["message: invalid input", "status: failed"])Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Test<'a>
impl<'a> RefUnwindSafe for Test<'a>
impl<'a> Send for Test<'a>
impl<'a> Sync for Test<'a>
impl<'a> Unpin for Test<'a>
impl<'a> UnwindSafe for Test<'a>
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