xtd 0.2.0
xtd::tunit::string_assert Class Referencefinal

Definition

The string_assert class contains a collection of static methods that implement the most string assertions used in xtd::tUnit.

Namespace
xtd::tunit
Library
xtd.tunit
Remarks
Assertions are central to unit testing in any of the xUnit frameworks, and xtd.tunit is no exception. xtd.tunit provides a rich set of assertions as static methods of the Assert class.
If an assertion fails, the method call does not return and an error is reported. If a test contains multiple assertions, any that follow the one that failed will not be executed. For this reason, it's usually best to try for one assertion per test.
Each method may be called without a message, with a simple text message or with a message and arguments. In the last case the message is formatted using the provided text and arguments.
Examples
This example show how to used some methods :
#include <xtd/xtd.tunit>
#include <stdexcept>
using namespace std;
using namespace xtd::io;
using namespace xtd::tunit;
namespace unit_tests {
// The class test must be declared with test_class_ helper.
class test_class_(test) {
public:
void test_method_(test_case1) {
auto s = "A string value";
}
void test_method_(test_case2) {
auto s = "A string value";
}
void test_method_(test_case3) {
auto s = "A string value";
}
};
}
auto main()->int {
return console_unit_test().run();
}
// This code can produce the following output:
//
// Start 3 tests from 1 test case
// Run tests:
// SUCCEED test.test_case1 (0 ms total)
// FAILED test.test_case2 (0 ms total)
// Expected: string containing "item"
// But was: "A string value"
// Stack Trace: in |---OMITTED---|/string_assert.cpp:17
// FAILED test.test_case3 (0 ms total)
// Expected: string matching "item$"
// But was: "A string value"
// Stack Trace: in |---OMITTED---|/string_assert.cpp:22
//
// Test results:
// SUCCEED 1 test.
// FAILED 2 tests.
// End 3 tests from 1 test case ran. (0 ms total)

Methods

static void are_equal_ignoring_case (const xtd::ustring &expected, const xtd::ustring &actual)
 Asserts that two type are equal ignoring case. More...
 
static void are_equal_ignoring_case (const xtd::ustring &expected, const xtd::ustring &actual, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two type are equal ignoring case. More...
 
static void are_equal_ignoring_case (const xtd::ustring &expected, const xtd::ustring &actual, const xtd::ustring &message)
 Asserts that two type are equal ignoring case. More...
 
static void are_equal_ignoring_case (const xtd::ustring &expected, const xtd::ustring &actual, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two type are equal ignoring case. More...
 
static void are_not_equal_ignoring_case (const xtd::ustring &expected, const xtd::ustring &actual)
 Asserts that two type are not equal ignoring case. More...
 
static void are_not_equal_ignoring_case (const xtd::ustring &expected, const xtd::ustring &actual, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two type are not equal ignoring case. More...
 
static void are_not_equal_ignoring_case (const xtd::ustring &expected, const xtd::ustring &actual, const xtd::ustring &message)
 Asserts that two type are not equal ignoring case. More...
 
static void are_not_equal_ignoring_case (const xtd::ustring &expected, const xtd::ustring &actual, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that two type are not equal ignoring case. More...
 
static void contains (const xtd::ustring &item, const xtd::ustring &string)
 Asserts that string contains an item. More...
 
static void contains (const xtd::ustring &item, const xtd::ustring &string, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string contains an item. More...
 
static void contains (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message)
 Asserts that string contains an item. More...
 
static void contains (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string contains an item. More...
 
static void does_not_contain (const xtd::ustring &item, const xtd::ustring &string)
 Asserts that string contains an item. More...
 
static void does_not_contain (const xtd::ustring &item, const xtd::ustring &string, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string contains an item. More...
 
static void does_not_contain (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message)
 Asserts that string contains an item. More...
 
static void does_not_contain (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string contains an item. More...
 
static void does_not_end_with (const xtd::ustring &item, const xtd::ustring &string)
 Asserts that string does not end with a specific item. More...
 
static void does_not_end_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string starts with item. More...
 
static void does_not_end_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message)
 Asserts that string starts with item. More...
 
static void does_not_end_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string starts with item. More...
 
static void does_not_match (const xtd::ustring &regex_pattern, const xtd::ustring &actual)
 Asserts that does not match regex pattern. More...
 
static void does_not_match (const xtd::ustring &regex_pattern, const xtd::ustring &actual, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that does not match regex pattern. More...
 
static void does_not_match (const xtd::ustring &regex_pattern, const xtd::ustring &actual, const xtd::ustring &message)
 Asserts that does not match regex pattern. More...
 
static void does_not_match (const xtd::ustring &regex_pattern, const xtd::ustring &actual, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that does not match regex pattern. More...
 
static void does_not_start_with (const xtd::ustring &item, const xtd::ustring &string)
 Asserts that string does not start with a specific item. More...
 
static void does_not_start_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string starts with item. More...
 
static void does_not_start_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message)
 Asserts that string starts with item. More...
 
static void does_not_start_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string starts with item. More...
 
static void ends_with (const xtd::ustring &item, const xtd::ustring &string)
 Asserts that string ends with a specific item. More...
 
static void ends_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string starts with item. More...
 
static void ends_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message)
 Asserts that string starts with item. More...
 
static void ends_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string starts with item. More...
 
static void matches (const xtd::ustring &regex_pattern, const xtd::ustring &actual)
 Asserts that matches regex pattern. More...
 
static void matches (const xtd::ustring &regex_pattern, const xtd::ustring &actual, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that matches regex pattern. More...
 
static void matches (const xtd::ustring &regex_pattern, const xtd::ustring &actual, const xtd::ustring &message)
 Asserts that matches regex pattern. More...
 
static void matches (const xtd::ustring &regex_pattern, const xtd::ustring &actual, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that matches regex pattern. More...
 
static void starts_with (const xtd::ustring &item, const xtd::ustring &string)
 Asserts that string starts witdh item. More...
 
static void starts_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string starts with item. More...
 
static void starts_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message)
 Asserts that string starts with item. More...
 
static void starts_with (const xtd::ustring &item, const xtd::ustring &string, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Asserts that string starts with item. More...
 

Member Function Documentation

◆ are_equal_ignoring_case() [1/4]

static void xtd::tunit::string_assert::are_equal_ignoring_case ( const xtd::ustring expected,
const xtd::ustring actual 
)
static

Asserts that two type are equal ignoring case.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::are_equal_ignoring_case("key", xtd::ustring("VALUE")); // test throws an assert_error exception.

◆ are_equal_ignoring_case() [2/4]

static void xtd::tunit::string_assert::are_equal_ignoring_case ( const xtd::ustring expected,
const xtd::ustring actual,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that two type are equal ignoring case.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::are_equal_ignoring_case("key", xtd::ustring("VALUE"), csf_); // test throws an assert_error exception.

◆ are_equal_ignoring_case() [3/4]

static void xtd::tunit::string_assert::are_equal_ignoring_case ( const xtd::ustring expected,
const xtd::ustring actual,
const xtd::ustring message 
)
static

Asserts that two type are equal ignoring case.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::are_equal_ignoring_case("value", xtd::ustring("VALUE"), "User message..."); // test ok.
xtd::tunit::string_assert::are_equal_ignoring_case("key", xtd::ustring("VALUE"), "User message..."); // test throws an assert_error exception.

◆ are_equal_ignoring_case() [4/4]

static void xtd::tunit::string_assert::are_equal_ignoring_case ( const xtd::ustring expected,
const xtd::ustring actual,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that two type are equal ignoring case.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::are_equal_ignoring_case("value", xtd::ustring("VALUE"), "User message...", csf_); // test ok.
xtd::tunit::string_assert::are_equal_ignoring_case("key", xtd::ustring("VALUE"), "User message...", csf_); // test throws an assert_error exception.

◆ are_not_equal_ignoring_case() [1/4]

static void xtd::tunit::string_assert::are_not_equal_ignoring_case ( const xtd::ustring expected,
const xtd::ustring actual 
)
static

Asserts that two type are not equal ignoring case.

Parameters
expectedthe expected value.
actualthe actual value.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::are_not_equal_ignoring_case("value", xtd::ustring("VALUE")); // test throws an assert_error exception.

◆ are_not_equal_ignoring_case() [2/4]

static void xtd::tunit::string_assert::are_not_equal_ignoring_case ( const xtd::ustring expected,
const xtd::ustring actual,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that two type are not equal ignoring case.

Parameters
expectedthe expected value.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::are_not_equal_ignoring_case("value", xtd::ustring("VALUE"), csf_); // test throws an assert_error exception.

◆ are_not_equal_ignoring_case() [3/4]

static void xtd::tunit::string_assert::are_not_equal_ignoring_case ( const xtd::ustring expected,
const xtd::ustring actual,
const xtd::ustring message 
)
static

Asserts that two type are not equal ignoring case.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::are_not_equal_ignoring_case("key", xtd::ustring("VALUE"), "User message..."); // test ok.
xtd::tunit::string_assert::are_not_equal_ignoring_case("value", xtd::ustring("VALUE"), "User message..."); // test throws an assert_error exception.

◆ are_not_equal_ignoring_case() [4/4]

static void xtd::tunit::string_assert::are_not_equal_ignoring_case ( const xtd::ustring expected,
const xtd::ustring actual,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that two type are not equal ignoring case.

Parameters
expectedthe expected value.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::are_not_equal_ignoring_case("key", xtd::ustring("VALUE"), "User message...", csf_); // test ok.
xtd::tunit::string_assert::are_not_equal_ignoring_case("value", xtd::ustring("VALUE"), "User message...", csf_); // test throws an assert_error exception.

◆ contains() [1/4]

static void xtd::tunit::string_assert::contains ( const xtd::ustring item,
const xtd::ustring string 
)
static

Asserts that string contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::contains("z", s); // test throws an assert_error exception.

◆ contains() [2/4]

static void xtd::tunit::string_assert::contains ( const xtd::ustring item,
const xtd::ustring string,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::contains("a", s, csf_); // test ok.
xtd::tunit::string_assert::contains("z", s, csf_); // test throws an assert_error exception.

◆ contains() [3/4]

static void xtd::tunit::string_assert::contains ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message 
)
static

Asserts that string contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::contains("a", s, "User message..."); // test ok.
xtd::tunit::string_assert::contains("z", s, "User message..."); // test throws an assert_error exception.

◆ contains() [4/4]

static void xtd::tunit::string_assert::contains ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::contains("a", s, "User message...", csf_); // test ok.
xtd::tunit::string_assert::contains("z", s, "User message...", csf_); // test throws an assert_error exception.

◆ does_not_contain() [1/4]

static void xtd::tunit::string_assert::does_not_contain ( const xtd::ustring item,
const xtd::ustring string 
)
static

Asserts that string contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::contains("z", s); // test throws an assert_error exception.

◆ does_not_contain() [2/4]

static void xtd::tunit::string_assert::does_not_contain ( const xtd::ustring item,
const xtd::ustring string,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::contains("a", s, csf_); // test ok.
xtd::tunit::string_assert::contains("z", s, csf_); // test throws an assert_error exception.

◆ does_not_contain() [3/4]

static void xtd::tunit::string_assert::does_not_contain ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message 
)
static

Asserts that string contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::contains("a", s, "User message..."); // test ok.
xtd::tunit::string_assert::contains("z", s, "User message..."); // test throws an assert_error exception.

◆ does_not_contain() [4/4]

static void xtd::tunit::string_assert::does_not_contain ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string contains an item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::contains("a", s, "User message...", csf_); // test ok.
xtd::tunit::string_assert::contains("z", s, "User message...", csf_); // test throws an assert_error exception.

◆ does_not_end_with() [1/4]

static void xtd::tunit::string_assert::does_not_end_with ( const xtd::ustring item,
const xtd::ustring string 
)
static

Asserts that string does not end with a specific item.

Parameters
itemobject to verify.
collectionthat contains object.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::does_not_end_with("lue", s); // test throws an assert_error exception.

◆ does_not_end_with() [2/4]

static void xtd::tunit::string_assert::does_not_end_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::does_not_end_with("lue", s, csf_); // test throws an assert_error exception.

◆ does_not_end_with() [3/4]

static void xtd::tunit::string_assert::does_not_end_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::does_not_end_with("law", s, "User message..."); // test ok.
xtd::tunit::string_assert::does_not_end_with("lue", s, "User message..."); // test throws an assert_error exception.

◆ does_not_end_with() [4/4]

static void xtd::tunit::string_assert::does_not_end_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::does_not_end_with("law", s, "User message...", csf_); // test ok.
xtd::tunit::string_assert::does_not_end_with("lue", s, "User message...", csf_); // test throws an assert_error exception.

◆ does_not_match() [1/4]

static void xtd::tunit::string_assert::does_not_match ( const xtd::ustring regex_pattern,
const xtd::ustring actual 
)
static

Asserts that does not match regex pattern.

Parameters
regex_patternthe regex pattern.
actualthe actual value.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::does_not_match("^Salut", xtd::ustring("Hello, World!")); // test ok.
xtd::tunit::string_assert::does_not_match("^Hello", xtd::ustring("Hello, World!")); // test throws an assert_error exception.

◆ does_not_match() [2/4]

static void xtd::tunit::string_assert::does_not_match ( const xtd::ustring regex_pattern,
const xtd::ustring actual,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that does not match regex pattern.

Parameters
regex_patternthe regex pattern.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::does_not_match("^Salut", xtd::ustring("Hello, World!"), csf_); // test ok.
xtd::tunit::string_assert::does_not_match("^Hello", xtd::ustring("Hello, World!"), csf_); // test throws an assert_error exception.

◆ does_not_match() [3/4]

static void xtd::tunit::string_assert::does_not_match ( const xtd::ustring regex_pattern,
const xtd::ustring actual,
const xtd::ustring message 
)
static

Asserts that does not match regex pattern.

Parameters
regex_patternthe regex pattern.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::does_not_match("^Salut", xtd::ustring("Hello, World!"), "User message..."); // test ok.
xtd::tunit::string_assert::does_not_match("^Hello", xtd::ustring("Hello, World!"), "User message..."); // test throws an assert_error exception.

◆ does_not_match() [4/4]

static void xtd::tunit::string_assert::does_not_match ( const xtd::ustring regex_pattern,
const xtd::ustring actual,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that does not match regex pattern.

Parameters
regex_patternthe regex pattern.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::does_not_match("^Salut", "Hello, World!", xtd::ustring("User message..."), csf_); // test ok.
xtd::tunit::string_assert::does_not_match("^Hello", "Hello, World!", xtd::ustring("User message..."), csf_); // test throws an assert_error exception.

◆ does_not_start_with() [1/4]

static void xtd::tunit::string_assert::does_not_start_with ( const xtd::ustring item,
const xtd::ustring string 
)
static

Asserts that string does not start with a specific item.

Parameters
itemobject to verify.
collectionthat contains object.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::does_not_start_with("val", s); // test throws an assert_error exception.

◆ does_not_start_with() [2/4]

static void xtd::tunit::string_assert::does_not_start_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::does_not_start_with("val", s, csf_); // test throws an assert_error exception.

◆ does_not_start_with() [3/4]

static void xtd::tunit::string_assert::does_not_start_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::does_not_start_with("zoe", s, "User message..."); // test ok.
xtd::tunit::string_assert::does_not_start_with("val", s, "User message..."); // test throws an assert_error exception.

◆ does_not_start_with() [4/4]

static void xtd::tunit::string_assert::does_not_start_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::does_not_start_with("zoe", s, "User message...", csf_); // test ok.
xtd::tunit::string_assert::does_not_start_with("val", s, "User message...", csf_); // test throws an assert_error exception.

◆ ends_with() [1/4]

static void xtd::tunit::string_assert::ends_with ( const xtd::ustring item,
const xtd::ustring string 
)
static

Asserts that string ends with a specific item.

Parameters
itemobject to verify.
collectionthat contains object.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::ends_with("law", s); // test throws an assert_error exception.

◆ ends_with() [2/4]

static void xtd::tunit::string_assert::ends_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::ends_with("val", s, csf_); // test ok.
xtd::tunit::string_assert::ends_with("law", s, csf_); // test throws an assert_error exception.

◆ ends_with() [3/4]

static void xtd::tunit::string_assert::ends_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::ends_with("val", s, "User message..."); // test ok.
xtd::tunit::string_assert::ends_with("law", s, "User message..."); // test throws an assert_error exception.

◆ ends_with() [4/4]

static void xtd::tunit::string_assert::ends_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::ends_with("lue", s, "User message...", csf_); // test ok.
xtd::tunit::string_assert::ends_with("law", s, "User message...", csf_); // test throws an assert_error exception.

◆ matches() [1/4]

static void xtd::tunit::string_assert::matches ( const xtd::ustring regex_pattern,
const xtd::ustring actual 
)
static

Asserts that matches regex pattern.

Parameters
regex_patternthe regex pattern.
actualthe actual value.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::matches("^Hello", xtd::ustring("Hello, World!")); // test ok.
xtd::tunit::string_assert::matches("^Salut", xtd::ustring("Hello, World!")); // test throws an assert_error exception.

◆ matches() [2/4]

static void xtd::tunit::string_assert::matches ( const xtd::ustring regex_pattern,
const xtd::ustring actual,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that matches regex pattern.

Parameters
regex_patternthe regex pattern.
actualthe actual value.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::matches("^Hello", xtd::ustring("Hello, World!"), csf_); // test ok.
xtd::tunit::string_assert::matches("^Salut", xtd::ustring("Hello, World!"), csf_); // test throws an assert_error exception.

◆ matches() [3/4]

static void xtd::tunit::string_assert::matches ( const xtd::ustring regex_pattern,
const xtd::ustring actual,
const xtd::ustring message 
)
static

Asserts that matches regex pattern.

Parameters
regex_patternthe regex pattern.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::matches("^Hello", xtd::ustring("Hello, World!"), "User message..."); // test ok.
xtd::tunit::string_assert::matches("^Salut", xtd::ustring("Hello, World!"), "User message..."); // test throws an assert_error exception.

◆ matches() [4/4]

static void xtd::tunit::string_assert::matches ( const xtd::ustring regex_pattern,
const xtd::ustring actual,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that matches regex pattern.

Parameters
regex_patternthe regex pattern.
actualthe actual value.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::tunit::string_assert::matches("^Hello", "Hello, World!", xtd::ustring("User message..."), csf_); // test ok.
xtd::tunit::string_assert::matches("^Salut", "Hello, World!", xtd::ustring("User message..."), csf_); // test throws an assert_error exception.

◆ starts_with() [1/4]

static void xtd::tunit::string_assert::starts_with ( const xtd::ustring item,
const xtd::ustring string 
)
static

Asserts that string starts witdh item.

Parameters
itemobject to verify.
collectionthat contains object.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::starts_with("zoe", s); // test throws an assert_error exception.

◆ starts_with() [2/4]

static void xtd::tunit::string_assert::starts_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::starts_with("val", s, csf_); // test ok.
xtd::tunit::string_assert::starts_with("zoe", s, csf_); // test throws an assert_error exception.

◆ starts_with() [3/4]

static void xtd::tunit::string_assert::starts_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::starts_with("val", s, "User message..."); // test ok.
xtd::tunit::string_assert::starts_with("zoe", s, "User message..."); // test throws an assert_error exception.

◆ starts_with() [4/4]

static void xtd::tunit::string_assert::starts_with ( const xtd::ustring item,
const xtd::ustring string,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Asserts that string starts with item.

Parameters
itemobject to verify.
collectionthat contains object.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
stack_frameContains information about current file and current line.
Exceptions
xtd::tunit::assert_errorIf bad assertion.
Examples
xtd::ustring s = "value";
xtd::tunit::string_assert::starts_with("val", s, "User message...", csf_); // test ok.
xtd::tunit::string_assert::starts_with("zoe", s, "User message...", csf_); // test throws an assert_error exception.

The documentation for this class was generated from the following file: