diff options
author | 2016-11-12 14:54:21 +0100 | |
---|---|---|
committer | 2016-11-12 14:54:21 +0100 | |
commit | 75c6c0f059c955f0fa8b5f99e30dc650f0503147 (patch) | |
tree | e543dcf4ff8fff9a49f0e291d1657fe22d9a9121 /tests/lib | |
parent | 3c577aedb88337775be37d564b6ebe1a3d74c8c3 (diff) |
Make executable for test follow rules for main file (nw)
Make normal notation for require (nw)
Split properly tests (nw)
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/util/corestr.cpp | 32 | ||||
-rw-r--r-- | tests/lib/util/options.cpp | 15 |
2 files changed, 36 insertions, 11 deletions
diff --git a/tests/lib/util/corestr.cpp b/tests/lib/util/corestr.cpp index 5bf752a4818..86774c92728 100644 --- a/tests/lib/util/corestr.cpp +++ b/tests/lib/util/corestr.cpp @@ -5,29 +5,39 @@ TEST_CASE("String make upper", "[util]") { std::string value = "test"; - REQUIRE("TEST" == strmakeupper(value)); + REQUIRE(strmakeupper(value) == "TEST"); } TEST_CASE("String make lower", "[util]") { std::string value = "ValUE"; - REQUIRE("value" == strmakelower(value)); + REQUIRE(strmakelower(value) == "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")); + REQUIRE(strreplace(value,"str","aaa") == 1); + REQUIRE(value == "Main aaaing"); + REQUIRE(strreplace(value,"a","b") == 4); } -TEST_CASE("String trimming", "[util]") +TEST_CASE("String replace counting", "[util]") +{ + std::string value = "Main aaaing"; + REQUIRE(strreplace(value,"a","b") == 4); +} + +TEST_CASE("String trimming spaces", "[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)); + REQUIRE(strtrimspace(value) == "a value for test"); +} + +TEST_CASE("String trimming all special", "[util]") +{ + std::string value = "\r\n\ta value for test\r\n\n\r"; + REQUIRE(strtrimspace(value) == "a value for test"); } TEST_CASE("String replace chars", "[util]") @@ -37,7 +47,7 @@ TEST_CASE("String replace chars", "[util]") strreplacechr(value,'e','E'); strreplacechr(value,'i','I'); strreplacechr(value,'o','O'); - REQUIRE("StrIng fOr dOIng rEplAcEs" == value); + REQUIRE(value == "StrIng fOr dOIng rEplAcEs"); } TEST_CASE("String delete char", "[util]") @@ -47,6 +57,6 @@ TEST_CASE("String delete char", "[util]") strdelchr(value,'e'); strdelchr(value,'i'); strdelchr(value,'o'); - REQUIRE("Strng fr dng dlts" == value); + REQUIRE(value == "Strng fr dng dlts"); } diff --git a/tests/lib/util/options.cpp b/tests/lib/util/options.cpp new file mode 100644 index 00000000000..e971a564521 --- /dev/null +++ b/tests/lib/util/options.cpp @@ -0,0 +1,15 @@ +#include "catch.hpp" + +#include "options.h" + +TEST_CASE("Empty options should return first as nullptr", "[util]") +{ + core_options options; + REQUIRE(options.first() == nullptr); +} + +TEST_CASE("Empty options should have iterators same", "[util]") +{ + core_options options; + REQUIRE(options.begin() == options.end()); +} |