summaryrefslogtreecommitdiffstatshomepage
path: root/tests/lib/util/corestr.cpp
blob: 5bf752a481890846a052cd23c8ff15aec8138b22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "catch.hpp"

#include "corestr.h"

TEST_CASE("String make upper", "[util]")
{
   std::string value = "test";
   REQUIRE("TEST" == strmakeupper(value));
}

TEST_CASE("String make lower", "[util]")
{
   std::string value = "ValUE";
   REQUIRE("value" == strmakelower(value));
}

TEST_CASE("String replace", "[util]")
{
   std::string value = "Main string";
   REQUIRE(1 == strreplace(value,"str","aaa"));
   REQUIRE("Main aaaing" == value);
   REQUIRE(4 == strreplace(value,"a","b"));
}

TEST_CASE("String trimming", "[util]")
{
   std::string value = "    a value  for test  ";
   REQUIRE("a value  for test" == strtrimspace(value));
   value = "\r\n\ta value  for test\r\n\n\r";
   REQUIRE("a value  for test" == strtrimspace(value));
}

TEST_CASE("String replace chars", "[util]")
{
   std::string value = "String for doing replaces";
   strreplacechr(value,'a','A');
   strreplacechr(value,'e','E');
   strreplacechr(value,'i','I');
   strreplacechr(value,'o','O');
   REQUIRE("StrIng fOr dOIng rEplAcEs" == value);
}

TEST_CASE("String delete char", "[util]")
{
   std::string value = "String for doing deletes";
   strdelchr(value,'a');
   strdelchr(value,'e');
   strdelchr(value,'i');
   strdelchr(value,'o');
   REQUIRE("Strng fr dng dlts" == value);
}