StringTools/Src/Test/Upper.cpp

73 lines
1.7 KiB
C++
Raw Normal View History

2022-02-11 01:32:43 +01:00
#include <StringTools/StringTools.h>
#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-11 09:36:29 +01:00
TEST_CASE(__FILE__"/EmptyString", "[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-11 09:36:29 +01:00
TEST_CASE(__FILE__"/Symbols", "[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-11 09:36:29 +01:00
TEST_CASE(__FILE__"/AlreadyUppered", "[Upper]")
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::Upper(in);
2022-02-11 01:32:43 +01:00
// Verify
REQUIRE(out == "UGHAREYOUSERIOUS");
return;
}
2022-02-11 01:32:43 +01:00
// Tests that uppering a string of lowercase letters returns the uppercase version
2022-02-11 09:36:29 +01:00
TEST_CASE(__FILE__"/Lowercase", "[Upper]")
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::Upper(in);
2022-02-11 01:32:43 +01:00
// Verify
REQUIRE(out == "UGHAREYOUSERIOUS");
return;
}
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-11 09:36:29 +01:00
TEST_CASE(__FILE__"/Mixed", "[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
}