Struct Case

Source
pub struct Case<T, G, P> {
    pub inputs: Vec<T>,
    pub params: Vec<P>,
    pub values: Vec<G>,
    /* private fields */
}
Expand description

Test case wrapper struct

§Generics

  • T - type of test inputs
  • G - type of expectations, must implement PartialEq and Display traits
  • P - type of optional parameters

Fields§

§inputs: Vec<T>

Input values of test case

§params: Vec<P>

Optional parameters when executing test case

§values: Vec<G>

Expected values of given input

Implementations§

Source§

impl<T, G, P> Case<T, G, P>
where T: PartialEq + Debug, G: PartialEq + Debug, P: PartialEq + Debug,

Source

pub fn new(input: T, values: Vec<G>) -> Case<T, G, P>

Create new test case with no parameters

§Arguments
  • input - test input
  • values - expected values, accept single- or multi-value vector
Source

pub fn new_multi(inputs: Vec<T>, values: Vec<G>) -> Case<T, G, P>

Create new test case with no parameters but multiple inputs

§Arguments
  • inputs - test input, accept single- or multi-value vector
  • values - expected values, accept single- or multi-value vector
Source

pub fn new_params(input: T, params: Vec<P>, values: Vec<G>) -> Case<T, G, P>

Create new test case with parameters

§Arguments
  • input - test input
  • params - test parameters that vary among different cases
  • values - expected values, accept single- or multi-value vector
Source

pub fn new_params_multi( inputs: Vec<T>, params: Vec<P>, values: Vec<G>, ) -> Case<T, G, P>

Create new test case with parameters and multi input

§Arguments
  • inputs - test input, accept single- or multi-value vector
  • params - test parameters that vary among different cases
  • values - expected values, accept single- or multi-value vector
Source

pub fn is_valid(&self, result: G)

Check if solution output matches any expectations

§Arguments
  • &self - inmutable borrow to object itself
  • result - solution output
use leetcode_rust::common::Case;
let case:Case<String, String, i32> = Case::new(String::from("A"), vec![String::from("A")]);
case.is_valid(String::from("A"))
Source

pub fn label(&self) -> String

Returns the index value in String form.

Source

pub fn input(&self) -> &T

Returns the first element of inputs

Auto Trait Implementations§

§

impl<T, G, P> Freeze for Case<T, G, P>

§

impl<T, G, P> RefUnwindSafe for Case<T, G, P>

§

impl<T, G, P> Send for Case<T, G, P>
where T: Send, P: Send, G: Send,

§

impl<T, G, P> Sync for Case<T, G, P>
where T: Sync, P: Sync, G: Sync,

§

impl<T, G, P> Unpin for Case<T, G, P>
where T: Unpin, P: Unpin, G: Unpin,

§

impl<T, G, P> UnwindSafe for Case<T, G, P>
where T: UnwindSafe, P: UnwindSafe, G: UnwindSafe,

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.