pub trait StringAssertions {
Show 34 methods
// Required methods
fn is_empty(self) -> Self;
fn is_not_empty(self) -> Self;
fn has_char_length(self, expected_length: usize) -> Self;
fn has_char_length_less_than(self, length_bound: usize) -> Self;
fn has_char_length_less_than_or_equal_to(self, length_bound: usize) -> Self;
fn has_char_length_greater_than(self, length_bound: usize) -> Self;
fn has_char_length_greater_than_or_equal_to(
self,
length_bound: usize,
) -> Self;
fn has_char_length_different_to(self, unexpected_length: usize) -> Self;
fn has_byte_length(self, expected_length: usize) -> Self;
fn has_byte_length_less_than(self, length_bound: usize) -> Self;
fn has_byte_length_less_than_or_equal_to(self, length_bound: usize) -> Self;
fn has_byte_length_greater_than(self, length_bound: usize) -> Self;
fn has_byte_length_greater_than_or_equal_to(
self,
length_bound: usize,
) -> Self;
fn has_byte_length_different_to(self, unexpected_length: usize) -> Self;
fn contains_whitespace(self) -> Self;
fn does_not_contain_whitespace(self) -> Self;
fn contains_alphabetic_characters(self) -> Self;
fn does_not_contain_alphabetic_characters(self) -> Self;
fn contains_numeric_characters(self) -> Self;
fn does_not_contain_numeric_characters(self) -> Self;
fn contains_alphanumeric_characters(self) -> Self;
fn does_not_contain_alphanumeric_characters(self) -> Self;
fn contains_uppercase_letters(self) -> Self;
fn does_not_contain_uppercase_letters(self) -> Self;
fn contains_lowercase_letters(self) -> Self;
fn does_not_contain_lowercase_letters(self) -> Self;
fn contains_control_characters(self) -> Self;
fn does_not_contain_control_characters(self) -> Self;
fn is_trimmed(self) -> Self;
fn is_not_trimmed(self) -> Self;
fn is_ascii(self) -> Self;
fn is_not_ascii(self) -> Self;
fn to_chars(self) -> AssertThat<Vec<char>>;
fn to_bytes(self) -> AssertThat<Vec<u8>>;
}Expand description
An extension trait to be used on the output of assert_that with a String argument. This trait contains basic assertions on the string itself and individual characters. For comparing strings (such as contains, prefix, and suffix relations), see StringPatternAssertions.
Examples:
use kernal::prelude::*;
assert_that!("hello world!")
.is_not_empty()
.has_char_length(12)
.has_byte_length_less_than(15)
.contains_whitespace()
.does_not_contain_uppercase_letters()
.is_trimmed();Required Methods§
Sourcefn is_empty(self) -> Self
fn is_empty(self) -> Self
Asserts that the tested string is empty, i.e. contains no characters.
Sourcefn is_not_empty(self) -> Self
fn is_not_empty(self) -> Self
Asserts that the tested string is not empty, i.e. contains at least one character.
Sourcefn has_char_length(self, expected_length: usize) -> Self
fn has_char_length(self, expected_length: usize) -> Self
Asserts that the number of characters in the tested string is equal to the given
expected_length.
Sourcefn has_char_length_less_than(self, length_bound: usize) -> Self
fn has_char_length_less_than(self, length_bound: usize) -> Self
Asserts that the number of characters in the tested string is less than the given
length_bound.
Sourcefn has_char_length_less_than_or_equal_to(self, length_bound: usize) -> Self
fn has_char_length_less_than_or_equal_to(self, length_bound: usize) -> Self
Asserts that the number of characters in the tested string is less than or equal to the
given length_bound.
Sourcefn has_char_length_greater_than(self, length_bound: usize) -> Self
fn has_char_length_greater_than(self, length_bound: usize) -> Self
Asserts that the number of characters in the tested string is greater than the given
length_bound.
Sourcefn has_char_length_greater_than_or_equal_to(self, length_bound: usize) -> Self
fn has_char_length_greater_than_or_equal_to(self, length_bound: usize) -> Self
Asserts that the number of characters in the tested string is greater than or equal to the
given length_bound.
Sourcefn has_char_length_different_to(self, unexpected_length: usize) -> Self
fn has_char_length_different_to(self, unexpected_length: usize) -> Self
Asserts that the number of characters in the tested string is different to the given
unexpected_length.
Sourcefn has_byte_length(self, expected_length: usize) -> Self
fn has_byte_length(self, expected_length: usize) -> Self
Asserts that the number of bytes composing the tested string is equal to the given
expected_length.
Sourcefn has_byte_length_less_than(self, length_bound: usize) -> Self
fn has_byte_length_less_than(self, length_bound: usize) -> Self
Asserts that the number of bytes composing the tested string is less than the given
length_bound.
Sourcefn has_byte_length_less_than_or_equal_to(self, length_bound: usize) -> Self
fn has_byte_length_less_than_or_equal_to(self, length_bound: usize) -> Self
Asserts that the number of bytes composing the tested string is less than or equal to the
given length_bound.
Sourcefn has_byte_length_greater_than(self, length_bound: usize) -> Self
fn has_byte_length_greater_than(self, length_bound: usize) -> Self
Asserts that the number of bytes composing the tested string is greater than the given
length_bound.
Sourcefn has_byte_length_greater_than_or_equal_to(self, length_bound: usize) -> Self
fn has_byte_length_greater_than_or_equal_to(self, length_bound: usize) -> Self
Asserts that the number of bytes composing the tested string is greater than or equal to
the given length_bound.
Sourcefn has_byte_length_different_to(self, unexpected_length: usize) -> Self
fn has_byte_length_different_to(self, unexpected_length: usize) -> Self
Asserts that the number of bytes composing the tested string is different to the given
unexpected_length.
Sourcefn contains_whitespace(self) -> Self
fn contains_whitespace(self) -> Self
Asserts that the tested string contains at least one character which is classified as whitespace according to char::is_whitespace.
Sourcefn does_not_contain_whitespace(self) -> Self
fn does_not_contain_whitespace(self) -> Self
Asserts that the tested string contains no character which is classified as whitespace according to char::is_whitespace.
Sourcefn contains_alphabetic_characters(self) -> Self
fn contains_alphabetic_characters(self) -> Self
Asserts that the tested string contains at least one character which is classified as alphabetic according to char::is_alphabetic.
Sourcefn does_not_contain_alphabetic_characters(self) -> Self
fn does_not_contain_alphabetic_characters(self) -> Self
Asserts that the tested string contains no character which is classified as alphabetic according to char::is_alphabetic.
Sourcefn contains_numeric_characters(self) -> Self
fn contains_numeric_characters(self) -> Self
Asserts that the tested string contains at least one character which is classified as numeric according to char::is_numeric.
Sourcefn does_not_contain_numeric_characters(self) -> Self
fn does_not_contain_numeric_characters(self) -> Self
Asserts that the tested string contains no character which is classified as numeric according to char::is_numeric.
Sourcefn contains_alphanumeric_characters(self) -> Self
fn contains_alphanumeric_characters(self) -> Self
Asserts that the tested string contains at least one character which is classified as alphanumeric according to char::is_alphanumeric.
Sourcefn does_not_contain_alphanumeric_characters(self) -> Self
fn does_not_contain_alphanumeric_characters(self) -> Self
Asserts that the tested string contains no character which is classified as alphanumeric according to char::is_alphanumeric.
Sourcefn contains_uppercase_letters(self) -> Self
fn contains_uppercase_letters(self) -> Self
Asserts that the tested string contains at least one character which is classified as an uppercase letter according to char::is_uppercase.
Sourcefn does_not_contain_uppercase_letters(self) -> Self
fn does_not_contain_uppercase_letters(self) -> Self
Asserts that the tested string contains no character which is classified as an uppercase letter according to char::is_uppercase.
Sourcefn contains_lowercase_letters(self) -> Self
fn contains_lowercase_letters(self) -> Self
Asserts that the tested string contains at least one character which is classified as a lowercase letter according to char::is_lowercase.
Sourcefn does_not_contain_lowercase_letters(self) -> Self
fn does_not_contain_lowercase_letters(self) -> Self
Asserts that the tested string contains no character which is classified as a lowercase letter according to char::is_lowercase.
Sourcefn contains_control_characters(self) -> Self
fn contains_control_characters(self) -> Self
Asserts that the tested string contains at least one character which is classified as a control character according to char::is_control.
Sourcefn does_not_contain_control_characters(self) -> Self
fn does_not_contain_control_characters(self) -> Self
Asserts that the tested string contains no character which is classified as a control character according to char::is_control.
Sourcefn is_trimmed(self) -> Self
fn is_trimmed(self) -> Self
Asserts that the tested string is trimmed, i.e. does not start and does not end with whitespace.
Sourcefn is_not_trimmed(self) -> Self
fn is_not_trimmed(self) -> Self
Asserts that the tested string is not trimmed, i.e. starts or ends with whitespace.
Sourcefn is_ascii(self) -> Self
fn is_ascii(self) -> Self
Asserts that the tested string is pure ASCII, i.e. contains no non-ASCII characters according to char::is_ascii.
Sourcefn is_not_ascii(self) -> Self
fn is_not_ascii(self) -> Self
Asserts that the tested string is not pure ASCII, i.e. contains at least one non-ASCII character according to char::is_ascii.
Sourcefn to_chars(self) -> AssertThat<Vec<char>>
fn to_chars(self) -> AssertThat<Vec<char>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.