Struct smoothy::BasicAsserter
source · pub struct BasicAsserter<AssertedType> { /* private fields */ }Expand description
Main struct with various assertions on AssertedType
Implementations§
source§impl<AssertedType> BasicAsserter<AssertedType>where
AssertedType: PartialEq + Debug,
impl<AssertedType> BasicAsserter<AssertedType>where AssertedType: PartialEq + Debug,
sourcepub fn equals(self, expected: impl Into<AssertedType>)
pub fn equals(self, expected: impl Into<AssertedType>)
Asserts that the assertable is equal to the expected value.
This is done by transforming the expected-value to a instance of AssertedType by using the Into-trait
and then comparing both values with PartialEq
Examples
assert_that(String::from("Hello World!")).equals("Hello World!");Panics
When the values are not matching according to PartialEq
source§impl<AssertedType> BasicAsserter<AssertedType>where
AssertedType: PartialEq + Debug,
impl<AssertedType> BasicAsserter<AssertedType>where AssertedType: PartialEq + Debug,
source§impl<AssertedType> BasicAsserter<AssertedType>where
AssertedType: PartialEq + Debug,
impl<AssertedType> BasicAsserter<AssertedType>where AssertedType: PartialEq + Debug,
source§impl<AssertedType> BasicAsserter<AssertedType>where
AssertedType: PartialEq + Debug,
impl<AssertedType> BasicAsserter<AssertedType>where AssertedType: PartialEq + Debug,
sourcepub fn not_equals(self, expected: impl Into<AssertedType>)
pub fn not_equals(self, expected: impl Into<AssertedType>)
Asserts that the assertable is not equal to the expected value.
This is done by transforming the expected-value to a instance of AssertedType by using the Into-trait
and then comparing both values with PartialEq
Examples
assert_that(String::from("Hello World!")).not_equals("Hello There!");Panics
When the values are matching according to PartialEq
source§impl<AssertedType> BasicAsserter<AssertedType>where
AssertedType: ToString,
impl<AssertedType> BasicAsserter<AssertedType>where AssertedType: ToString,
sourcepub fn to_string(self) -> BasicAsserter<String>
pub fn to_string(self) -> BasicAsserter<String>
Converts the assertable to a string for futher assertions
Examples
let asserter: BasicAsserter<String> = assert_that(42).to_string();
// further assertions
asserter.equals("42");source§impl<AssertedType> BasicAsserter<AssertedType>where
AssertedType: PartialEq + Debug,
impl<AssertedType> BasicAsserter<AssertedType>where AssertedType: PartialEq + Debug,
sourcepub fn try_into_equals<T>(self, expected: T)where
T: TryInto<AssertedType>,
<T as TryInto<AssertedType>>::Error: Debug,
pub fn try_into_equals<T>(self, expected: T)where T: TryInto<AssertedType>, <T as TryInto<AssertedType>>::Error: Debug,
Asserts that the assertable is equal to the expected value.
This is done by transforming the expected-value to a instance of AssertedType by using the TryInto-trait
and then comparing both values with PartialEq
Examples
assert_that(42u8).try_into_equals(42i8);Panics
When the transformation fails or the values are not matching according to PartialEq
source§impl<AssertedType> BasicAsserter<AssertedType>where
AssertedType: PartialEq + Debug,
impl<AssertedType> BasicAsserter<AssertedType>where AssertedType: PartialEq + Debug,
sourcepub fn try_into_not_equals<T>(self, expected: T)where
T: TryInto<AssertedType>,
<T as TryInto<AssertedType>>::Error: Debug,
pub fn try_into_not_equals<T>(self, expected: T)where T: TryInto<AssertedType>, <T as TryInto<AssertedType>>::Error: Debug,
Asserts that the assertable is not equal to the expected value.
This is done by transforming the expected-value to a instance of AssertedType by using the TryInto-trait
and then comparing both values with PartialEq
Examples
assert_that(42u8).try_into_not_equals(100i8);Panics
When the transformation fails or the values are matching according to PartialEq