Start adding tests for string manip functions
This commit is contained in:
parent
4038ee6bc6
commit
b77ab74b72
7 changed files with 116 additions and 7 deletions
18
projects/SelfTest/IntrospectiveTests/StringManip.tests.cpp
Normal file
18
projects/SelfTest/IntrospectiveTests/StringManip.tests.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "internal/catch_string_manip.h"
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
static const char * const no_whitespace = "There is no extra whitespace here";
|
||||
static const char * const leading_whitespace = " \r \t\n There is no extra whitespace here";
|
||||
static const char * const trailing_whitespace = "There is no extra whitespace here \t \n \r ";
|
||||
static const char * const whitespace_at_both_ends = " \r\n \t There is no extra whitespace here \t\t\t \n";
|
||||
|
||||
TEST_CASE("Trim strings", "[string-manip]") {
|
||||
using Catch::trim; using Catch::StringRef;
|
||||
static_assert(std::is_same<std::string, decltype(trim(std::string{}))>::value, "Trimming std::string should return std::string");
|
||||
|
||||
REQUIRE(trim(std::string(no_whitespace)) == no_whitespace);
|
||||
REQUIRE(trim(std::string(leading_whitespace)) == no_whitespace);
|
||||
REQUIRE(trim(std::string(trailing_whitespace)) == no_whitespace);
|
||||
REQUIRE(trim(std::string(whitespace_at_both_ends)) == no_whitespace);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue