StringTools/Test/Lower.cpp

73 lines
1.7 KiB
C++
Raw Normal View History

2022-02-12 16:04:48 +01:00
#include <StringTools.h>
2022-02-11 01:32:43 +01:00
#include "Catch2.h"
2021-12-04 20:18:09 +01:00
2022-02-11 01:32:43 +01:00
// Tests that lowering an empty string returns an empty string
2022-02-11 09:36:29 +01:00
TEST_CASE(__FILE__"/EmptyString", "[Lower]")
2021-12-04 20:18:09 +01:00
{
2022-02-11 01:32:43 +01:00
// Setup
const std::string in = "";
2021-12-04 20:18:09 +01:00
2022-02-11 01:32:43 +01:00
// Exercise
const std::string out = StringTools::Lower(in);
2021-12-04 20:18:09 +01:00
2022-02-11 01:32:43 +01:00
// Verify
REQUIRE(out == "");
return;
}
2021-12-04 20:18:09 +01:00
2022-02-11 01:32:43 +01:00
// Tests that lowering a string without any letters returns itself
2022-02-11 09:36:29 +01:00
TEST_CASE(__FILE__"/Symbols", "[Lower]")
2022-02-11 01:32:43 +01:00
{
// Setup
const std::string in = "66! _-\n*";
2021-12-04 20:18:09 +01:00
2022-02-11 01:32:43 +01:00
// Exercise
const std::string out = StringTools::Lower(in);
2021-12-04 20:18:09 +01:00
2022-02-11 01:32:43 +01:00
// Verify
REQUIRE(out == "66! _-\n*");
return;
}
2021-12-04 20:18:09 +01:00
2022-02-11 01:32:43 +01:00
// Tests that lowering a string of lowercase letters returns itself
2022-02-11 09:36:29 +01:00
TEST_CASE(__FILE__"/AlreadyLowered", "[Lower]")
2022-02-11 01:32:43 +01:00
{
// Setup
const std::string in = "ughareyouserious";
2022-02-11 01:32:43 +01:00
// Exercise
const std::string out = StringTools::Lower(in);
2022-02-11 01:32:43 +01:00
// Verify
REQUIRE(out == "ughareyouserious");
return;
}
2022-02-11 01:32:43 +01:00
// Tests that lowering a string of uppercase letters returns the lowercase version
2022-02-11 09:36:29 +01:00
TEST_CASE(__FILE__"/Uppercase", "[Lower]")
2022-02-11 01:32:43 +01:00
{
// Setup
const std::string in = "UGHAREYOUSERIOUS";
2022-02-11 01:32:43 +01:00
// Exercise
const std::string out = StringTools::Lower(in);
2022-02-11 01:32:43 +01:00
// Verify
REQUIRE(out == "ughareyouserious");
return;
}
2022-02-11 01:32:43 +01:00
// Tests that lowering a string of uppercase, lowercase letters and symbols returns the lowercase version
2022-02-11 09:36:29 +01:00
TEST_CASE(__FILE__"/Mixed", "[Lower]")
2022-02-11 01:32:43 +01:00
{
// Setup
const std::string in = "Ugh, Are You Serious?! DON'T DO THAT!!!";
2021-12-04 20:18:09 +01:00
2022-02-11 01:32:43 +01:00
// Exercise
const std::string out = StringTools::Lower(in);
2021-12-04 20:18:09 +01:00
2022-02-11 01:32:43 +01:00
// Verify
REQUIRE(out == "ugh, are you serious?! don't do that!!!");
return;
2021-12-04 20:18:09 +01:00
}