Plan

Struct Plan 

Source
pub struct Plan<'a> {
    pub first: i32,
    pub last: i32,
    pub reason: Option<&'a str>,
}
Expand description

The Plan tells how many tests will be run, or how many tests have run.

Fields§

§first: i32

ID of first planned test. Should always start with 1.

§last: i32

ID of last planned test. A value of 0 should indicate no tests were executed.

§reason: Option<&'a str>

Arbitrary string which should indicate why the certain tests were skipped.

Implementations§

Source§

impl<'a> Plan<'a>

Source

pub fn parse_from_str(content: &'a str) -> Result<Self>

Parse Plan from a &str.

§Examples

Parsing a TAP plan may look like this:

use tapconsooomer::Plan;

let content = "1..5 # TODO: Test 3 may fail";
let plan = Plan::parse_from_str(content).expect("Parser error");
assert_eq!(plan.first, 1);
assert_eq!(plan.last, 5);
assert_eq!(plan.reason, Some("TODO: Test 3 may fail"));

Note, Plan::reason is optional:

use tapconsooomer::Plan;

let content = "1..5";
let plan = Plan::parse_from_str(content).expect("Parser error");
assert_eq!(plan.first, 1);
assert_eq!(plan.last, 5);
assert_eq!(plan.reason, None);

Trait Implementations§

Source§

impl<'a> Debug for Plan<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Serialize for Plan<'a>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Plan<'a>

§

impl<'a> RefUnwindSafe for Plan<'a>

§

impl<'a> Send for Plan<'a>

§

impl<'a> Sync for Plan<'a>

§

impl<'a> Unpin for Plan<'a>

§

impl<'a> UnwindSafe for Plan<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.