Skip to content

Commit

Permalink
add initial unittests for utility::string_equals and utility::lexical…
Browse files Browse the repository at this point in the history
…_cast.
  • Loading branch information
luca-schlecker committed Jun 7, 2022
1 parent a165d35 commit 6df15eb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3113,3 +3113,27 @@ TEST_CASE("trim")
CHECK(utility::trim(" a b ") == "a b");
CHECK(utility::trim(" ") == "");
}

TEST_CASE("string_equals")
{
CHECK(utility::string_equals("a", "aa") == false);
CHECK(utility::string_equals("a", "b") == false);
CHECK(utility::string_equals("", "") == true);
CHECK(utility::string_equals("abc", "abc") == true);
CHECK(utility::string_equals("ABC", "abc") == true);

CHECK(utility::string_equals("a", "aa", true) == false);
CHECK(utility::string_equals("a", "b", true) == false);
CHECK(utility::string_equals("", "", true) == true);
CHECK(utility::string_equals("abc", "abc", true) == true);
CHECK(utility::string_equals("ABC", "abc", true) == false);
}

TEST_CASE("lexical_cast")
{
CHECK(utility::lexical_cast<int>(4) == 4);
CHECK(utility::lexical_cast<double>(4) == 4.0);
CHECK(utility::lexical_cast<int>("5") == 5);
CHECK(utility::lexical_cast<string>(4) == "4");
CHECK(utility::lexical_cast<float>("10", 2) == 10.0f);
}

0 comments on commit 6df15eb

Please sign in to comment.