Struct leetcode_rust::common::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 inputsG
- type of expectations, must implementPartialEq
andDisplay
traitsP
- 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,
impl<T, G, P> Case<T, G, P>where
T: PartialEq + Debug,
G: PartialEq + Debug,
P: PartialEq + Debug,
sourcepub fn new(input: T, values: Vec<G>) -> Case<T, G, P>
pub fn new(input: T, values: Vec<G>) -> Case<T, G, P>
Create new test case with no parameters
Arguments
input
- test inputvalues
- expected values, accept single- or multi-value vector
sourcepub fn new_multi(inputs: Vec<T>, values: Vec<G>) -> Case<T, G, P>
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 vectorvalues
- expected values, accept single- or multi-value vector
sourcepub fn new_params(input: T, params: Vec<P>, values: Vec<G>) -> Case<T, G, P>
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 inputparams
- test parameters that vary among different casesvalues
- expected values, accept single- or multi-value vector
sourcepub fn new_params_multi(
inputs: Vec<T>,
params: Vec<P>,
values: Vec<G>
) -> Case<T, G, P>
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 vectorparams
- test parameters that vary among different casesvalues
- expected values, accept single- or multi-value vector
sourcepub fn is_valid(&self, result: G)
pub fn is_valid(&self, result: G)
Check if solution output matches any expectations
Arguments
&self
- inmutable borrow to object itselfresult
- 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"))