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:29:17 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Tests that uppering an empty string returns an empty string
|
2022-02-12 20:07:48 +01:00
|
|
|
TEST_CASE(__FILE__"/EmptyString", "[Strings][Upper]")
|
2021-12-04 20:29:17 +01:00
|
|
|
{
|
2022-02-11 01:32:43 +01:00
|
|
|
// Setup
|
|
|
|
const std::string in = "";
|
2021-12-04 20:29:17 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Exercise
|
|
|
|
const std::string out = StringTools::Upper(in);
|
2021-12-04 20:29:17 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Verify
|
|
|
|
REQUIRE(out == "");
|
|
|
|
return;
|
|
|
|
}
|
2021-12-04 20:29:17 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Tests that uppering a string without any letters returns itself
|
2022-02-12 20:07:48 +01:00
|
|
|
TEST_CASE(__FILE__"/Symbols", "[Strings][Upper]")
|
2022-02-11 01:32:43 +01:00
|
|
|
{
|
|
|
|
// Setup
|
|
|
|
const std::string in = "66! _-\n*";
|
2021-12-04 20:29:17 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Exercise
|
|
|
|
const std::string out = StringTools::Upper(in);
|
2021-12-04 20:29:17 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Verify
|
|
|
|
REQUIRE(out == "66! _-\n*");
|
|
|
|
return;
|
|
|
|
}
|
2021-12-04 20:29:17 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Tests that uppering a string of uppercase letters returns itself
|
2022-02-12 20:07:48 +01:00
|
|
|
TEST_CASE(__FILE__"/AlreadyUppered", "[Strings][Upper]")
|
2022-02-11 01:32:43 +01:00
|
|
|
{
|
|
|
|
// Setup
|
|
|
|
const std::string in = "UGHAREYOUSERIOUS";
|
2021-12-04 20:36:24 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Exercise
|
|
|
|
const std::string out = StringTools::Upper(in);
|
2021-12-04 20:36:24 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Verify
|
|
|
|
REQUIRE(out == "UGHAREYOUSERIOUS");
|
|
|
|
return;
|
|
|
|
}
|
2021-12-04 20:36:24 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Tests that uppering a string of lowercase letters returns the uppercase version
|
2022-02-12 20:07:48 +01:00
|
|
|
TEST_CASE(__FILE__"/Lowercase", "[Strings][Upper]")
|
2022-02-11 01:32:43 +01:00
|
|
|
{
|
|
|
|
// Setup
|
|
|
|
const std::string in = "ughareyouserious";
|
2021-12-04 20:36:24 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Exercise
|
|
|
|
const std::string out = StringTools::Upper(in);
|
2021-12-04 20:36:24 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Verify
|
|
|
|
REQUIRE(out == "UGHAREYOUSERIOUS");
|
|
|
|
return;
|
|
|
|
}
|
2021-12-04 20:36:24 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Tests that uppering a string of uppercase, lowercase letters and symbols returns the uppercase version
|
2022-02-12 20:07:48 +01:00
|
|
|
TEST_CASE(__FILE__"/Mixed", "[Strings][Upper]")
|
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:29:17 +01:00
|
|
|
|
2022-02-11 01:32:43 +01:00
|
|
|
// Exercise
|
|
|
|
const std::string out = StringTools::Upper(in);
|
2021-12-04 20:29:17 +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:29:17 +01:00
|
|
|
}
|