mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Rename Contains string matcher builder to ContainsSubstring
The problem with the old name was that it collided with the range matcher `Contains`, and it was not really possible to disambiguate them just with argument types. Closes #2131
This commit is contained in:
@@ -35,10 +35,10 @@ operators, that is `&&`, `||`, and `!`, like so:
|
||||
|
||||
```cpp
|
||||
using Catch::Matchers::EndsWith;
|
||||
using Catch::Matchers::Contains;
|
||||
using Catch::Matchers::ContainsSubstring;
|
||||
|
||||
REQUIRE_THAT( getSomeString(),
|
||||
EndsWith("as a service") && Contains("web scale"));
|
||||
EndsWith("as a service") && ContainsSubstring("web scale"));
|
||||
```
|
||||
|
||||
The example above asserts that the string returned from `getSomeString`
|
||||
@@ -64,7 +64,7 @@ TEST_CASE("Bugs, bugs, bugs", "[Bug]"){
|
||||
std::string str = "Bugs as a service";
|
||||
|
||||
auto match_expression = Catch::Matchers::EndsWith( "as a service" ) ||
|
||||
(Catch::Matchers::StartsWith( "Big data" ) && !Catch::Matchers::Contains( "web scale" ) );
|
||||
(Catch::Matchers::StartsWith( "Big data" ) && !Catch::Matchers::ContainsSubstring( "web scale" ) );
|
||||
REQUIRE_THAT(str, match_expression);
|
||||
}
|
||||
```
|
||||
@@ -88,7 +88,7 @@ Out of the box, Catch2 provides the following matchers:
|
||||
Catch2 provides 5 different matchers that work with `std::string`,
|
||||
* `StartsWith(std::string str, CaseSensitive)`,
|
||||
* `EndsWith(std::string str, CaseSensitive)`,
|
||||
* `Contains(std::string str, CaseSensitive)`,
|
||||
* `ContainsSubstring(std::string str, CaseSensitive)`,
|
||||
* `Equals(std::string str, CaseSensitive)`, and
|
||||
* `Matches(std::string str, CaseSensitive)`.
|
||||
|
||||
|
Reference in New Issue
Block a user