Added tests for char tools

This commit is contained in:
Leonetienne 2022-02-12 20:07:48 +01:00
parent cf397f3af8
commit ab1a3672c3
15 changed files with 334 additions and 64 deletions

View File

@ -2,11 +2,13 @@
#include <algorithm>
bool CharTools::IsVowel(const char c, const std::string &vowels) {
const char lc = MakeLower(c);
return std::any_of(
vowels.cbegin(),
vowels.cend(),
[c](const char vowel) {
return c == vowel;
[lc](const char vowel) {
return lc == vowel;
}
);
}
@ -18,19 +20,28 @@ bool CharTools::IsLetter(const char c) {
return (lowercase_c >= 'a') && (lowercase_c <= 'z');
}
bool CharTools::IsGeneric(const char c) {
return (c == UPPERCASE) || (c == LOWERCASE);
bool CharTools::IsDigit(const char c) {
return (c >= '0') && (c <= '9');
}
bool CharTools::IsUpper(const char c) {
if ((!IsLetter(c)) && (!IsGeneric(c)))
if (!IsLetter(c))
return false;
else
return !(c & (1<<5));
}
bool CharTools::IsLower(const char c) {
// Can't just return !IsUpper(c), because it should still return false for digits and symbols...
if (!IsLetter(c))
return false;
else
return (c & (1<<5));
}
char CharTools::MakeUpper(char c) {
if ((!IsLetter(c)) && (!IsGeneric(c)))
if (!IsLetter(c))
return c;
else if (IsUpper(c))
return c;
@ -39,7 +50,7 @@ char CharTools::MakeUpper(char c) {
}
char CharTools::MakeLower(char c) {
if ((!IsLetter(c)) && (!IsGeneric(c)))
if (!IsLetter(c))
return c;
else if (!IsUpper(c))
return c;
@ -47,15 +58,8 @@ char CharTools::MakeLower(char c) {
return c | (1<<5);
}
char CharTools::GetSign(char c) {
if (IsUpper(c))
return UPPERCASE;
else
return LOWERCASE;
}
char CharTools::CopySign(char sign, char c) {
if ((!IsLetter(c)) && (!IsGeneric(c)))
if ((!IsLetter(c)) || (!IsLetter(sign)))
return c;
if (IsUpper(sign))
return MakeUpper(c);

View File

@ -8,34 +8,28 @@
class CharTools {
public:
//! Checks whether or not `c` is a vowel. You can define custom vowel characters.
static bool IsVowel(const char c, const std::string& vowels = "euioay");
static bool IsVowel(const char c, const std::string &vowels = "euioay");
//! Returns whether or not `c` is a letter.
static bool IsLetter(const char c);
//! Returns whether or not `c` is a generic character (that contains JUST the sign)
static bool IsGeneric(const char c);
//! Returns whether or not `c` is a digit.
static bool IsDigit(const char c);
//! Checks whether or not `c` is an uppercase character.
static bool IsUpper(const char c);
//! Checks whether or not `c` is a lowercase character.
static bool IsLower(const char c);
//! Will return `c` as an uppercase character.
static char MakeUpper(char c);
//! Will return `c` as a lowercase character.
static char MakeLower(char c);
//! Will return an empty character with the same sign/capitalization as `c`.
static char GetSign(char c);
//! Will return `c` with the same capitalization as `sign`.
static char CopySign(char sign, char c);
//! Generic uppercase character.
static constexpr char UPPERCASE = 0;
//! Generic lowercase character.
static constexpr char LOWERCASE = (1<<5);
};
#endif //STRINGTOOLS_CHARTOOLS_H

View File

@ -9,10 +9,22 @@ link_directories(../Src/cmake-build-debug)
add_executable(Test
Catch2.h
main.cpp
Lower.cpp
Upper.cpp
Replace_Char.cpp
Replace_String.cpp
# StringTools-Tests
String__Lower.cpp
String__Upper.cpp
String__Replace_Char.cpp
String__Replace_String.cpp
# CharTools-Tests
Char__IsVowel.cpp
Char__IsLetter.cpp
Char__IsDigit.cpp
Char__IsUpper.cpp
Char__IsLower.cpp
Char__MakeUpper.cpp
Char__MakeLower.cpp
Char__CopySign.cpp
)
target_link_libraries(Test StringTools)

69
Test/Char__CopySign.cpp Normal file
View File

@ -0,0 +1,69 @@
#include <CharTools.h>
#include "Catch2.h"
TEST_CASE(__FILE__"/JustChars", "[Char][CopySign]")
{
// Setup
// Correct letters
const std::string in = "tHEEuEUROPEanunioNCOnsiStsOFStATESIncLudingGERmanySWedenAndfRanCE";
// Correct signs
const std::string signs = "AaaAAApqlkzicZnionceroigjreiojiopjaopickwapPjfipojWqfpohoijFucmwp";
// Correct signs and letters
const std::string expected = "TheEUEuropeanUnionconsistsofstatesincludingGermanySwedenandFrance";
// Exercise
std::string out = in;
for (std::size_t i = 0; i < in.size(); i++)
{
const char cs = signs[i];
char& co = out[i];
co = CharTools::CopySign(cs, co);
}
// Verify:
REQUIRE(out == expected);
}
TEST_CASE(__FILE__"/WithSymbols", "[Char][CopySign]")
{
// Setup
// Correct letters
const std::string in = "ThE eu (euRoPeAN uNIon) cONsiSts Of 20 STAtes, iNCLUDInG GeRMAnY, sweden, aND fRancE.";
// Correct signs
const std::string signs = "DwefOPerKofkaqdioJeriofgjqeiopqwqefijoqgehjloivxcvmopfkuoQpwfioqjiOqgjeprjgnvqPemrqij";
// Correct signs and letters
const std::string expected = "The EU (European Union) consists of 20 states, including Germany, Sweden, and France.";
// Exercise
std::string out = in;
for (std::size_t i = 0; i < in.size(); i++)
{
const char cs = signs[i];
char& co = out[i];
co = CharTools::CopySign(cs, co);
}
// Verify:
REQUIRE(out == expected);
}
TEST_CASE(__FILE__"/DoesntChangeSignsIfSymbolSupplied", "[Char][CopySign]")
{
// Setup
const std::string in = "ThE eu (euRoPeAN uNIon) cONsiSts Of 20 STAtes, iNCLUDInG GeRMAnY, sweden, aND fRancE.";
const std::string signs = "!§$)=%164)';:'*?)/!?/&()()?)*'_;:_,.93ß04750928372!!$==)()/!§$)=%)*'';:'*?)/!1572?/&(";
const std::string expected = in;
// Exercise
std::string out = in;
for (std::size_t i = 0; i < in.size(); i++)
{
const char cs = signs[i];
char& co = out[i];
co = CharTools::CopySign(cs, co);
}
// Verify:
REQUIRE(out == expected);
}

20
Test/Char__IsDigit.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <CharTools.h>
#include "Catch2.h"
// Tests character digit-ness by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
{
// Setup
const std::string in = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHJIKLMNOPQRSTUVWXYZ!&/()=?*'#-.,;:_";
const std::string map = "000000000000000000000000001111111111000000000000000000000000000000000000000000";
// 0 -> no digit, 1 -> digit
// Verify that I didn't frick up compiling the map by hand
if (in.length() != map.length())
FAIL("map.size() does not match in.size(). (" << in.length() << " : " << map.length() << ")");
// Exercise & Verify
for (std::size_t i = 0; i < in.size(); i++)
if (CharTools::IsDigit(in[i]) != (map[i] == '1'))
FAIL("'" << in[i] << "' differs from the map. Map says '" << map[i] << "', 1-> is a digit. Check first if the map is wrong, before trying to debug.");
}

19
Test/Char__IsLetter.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <CharTools.h>
#include "Catch2.h"
// Tests character letter-ness by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsLetter]")
{
// Setup
const std::string in = "New album 'Cowboy Tears' out February 18! I am excited!";
const std::string map = "1110111110011111101111100111011111111000001011011111110"; // 0 -> no letter, 1 -> letter
// Verify that I didn't frick up compiling the map by hand
if (in.length() != map.length())
FAIL("map.size() does not match in.size(). (" << in.length() << " : " << map.length() << ")");
// Exercise & Verify
for (std::size_t i = 0; i < in.size(); i++)
if (CharTools::IsLetter(in[i]) != (map[i] == '1'))
FAIL("'" << in[i] << "' differs from the map. Map says '" << map[i] << "', 1-> is a letter. Check first if the map is wrong, before trying to debug.");
}

19
Test/Char__IsLower.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <CharTools.h>
#include "Catch2.h"
// Tests character sign by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsLower]")
{
// Setup
const std::string in = "New album 'Cowboy Tears' out February 18! I am excited!";
const std::string map = "0110111110001111100111100111001111111000000011011111110"; // 1 -> lowercase, 0 -> not lowercase
// Verify that I didn't frick up compiling the map by hand
if (in.length() != map.length())
FAIL("map.size() does not match in.size(). (" << in.length() << " : " << map.length() << ")");
// Exercise & Verify
for (std::size_t i = 0; i < in.size(); i++)
if (CharTools::IsLower(in[i]) != (map[i] == '1'))
FAIL("'" << in[i] << "' differs from the map. Map says '" << map[i] << "', 1-> is a lowercase. Check first if the map is wrong, before trying to debug.");
}

20
Test/Char__IsUpper.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <CharTools.h>
#include "Catch2.h"
#include <iostream>
// Tests character sign by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsUpper]")
{
// Setup
const std::string in = "New album 'Cowboy Tears' out February 18! I am excited!";
const std::string map = "1000000000010000001000000000010000000000001000000000000"; // 1 -> uppercase, 0 -> not uppercase
// Verify that I didn't frick up compiling the map by hand
if (in.length() != map.length())
FAIL("map.size() does not match in.size(). (" << in.length() << " : " << map.length() << ")");
// Exercise & Verify
for (std::size_t i = 0; i < in.size(); i++)
if (CharTools::IsUpper(in[i]) != (map[i] == '1'))
FAIL("'" << in[i] << "' differs from the map. Map says '" << map[i] << "', 1-> is an uppercase. Check first if the map is wrong, before trying to debug.");
}

19
Test/Char__IsVowel.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <CharTools.h>
#include "Catch2.h"
// Tests character vowel-ness by checking it against a map
TEST_CASE(__FILE__"/MapTest", "[Char][IsVowel]")
{
// Setup
const std::string in = "New album 'Cowboy Tears' out February 18! I am excited!";
const std::string map = "0100100100001001100110000110001001101000001010010010100"; // 0 -> no vowel, 1 -> vowel
// Verify that I didn't frick up compiling the map by hand
if (in.length() != map.length())
FAIL("map.size() does not match in.size(). (" << in.length() << " : " << map.length() << ")");
// Exercise & Verify
for (std::size_t i = 0; i < in.size(); i++)
if (CharTools::IsVowel(in[i]) != (map[i] == '1'))
FAIL("'" << in[i] << "' differs from the map. Map says '" << map[i] << "', 1-> is a vowel. Check first if the map is wrong, before trying to debug.");
}

47
Test/Char__MakeLower.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <CharTools.h>
#include "Catch2.h"
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeLower]")
{
// Setup
const std::string in = "NEWALBUMCOWBOYTEARSOUTFEBRUARYIAMEXCITED";
const std::string expected = "newalbumcowboytearsoutfebruaryiamexcited";
// Exercise
std::string out = in;
for (char& c : out)
c = CharTools::MakeLower(c);
// Verify:
REQUIRE(out == expected);
}
TEST_CASE(__FILE__"/LowerToUpper_Symbols", "[Char][MakeLower]")
{
// Setup
const std::string in = "NEW ALBUM 'COWBOY TEARS' OUT FEBRUARY 18! I AM EXCITED!";
const std::string expected = "new album 'cowboy tears' out february 18! i am excited!";
// Exercise
std::string out = in;
for (char& c : out)
c = CharTools::MakeLower(c);
// Verify:
REQUIRE(out == expected);
}
TEST_CASE(__FILE__"/LowerToUpper_Mixed_And_Symbols", "[Char][MakeLower]")
{
// Setup
const std::string in = "New album 'Cowboy Tears' out February 18! I am excited!";
const std::string expected = "new album 'cowboy tears' out february 18! i am excited!";
// Exercise
std::string out = in;
for (char& c : out)
c = CharTools::MakeLower(c);
// Verify:
REQUIRE(out == expected);
}

47
Test/Char__MakeUpper.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <CharTools.h>
#include "Catch2.h"
TEST_CASE(__FILE__"/LowerToUpper_NoSymbols", "[Char][MakeUpper]")
{
// Setup
const std::string in = "newalbumcowboytearsoutfebruaryiamexcited";
const std::string expected = "NEWALBUMCOWBOYTEARSOUTFEBRUARYIAMEXCITED";
// Exercise
std::string out = in;
for (char& c : out)
c = CharTools::MakeUpper(c);
// Verify:
REQUIRE(out == expected);
}
TEST_CASE(__FILE__"/LowerToUpper_Symbols", "[Char][MakeUpper]")
{
// Setup
const std::string in = "new album 'Cowboy Tears' out february 18! i am excited!";
const std::string expected = "NEW ALBUM 'COWBOY TEARS' OUT FEBRUARY 18! I AM EXCITED!";
// Exercise
std::string out = in;
for (char& c : out)
c = CharTools::MakeUpper(c);
// Verify:
REQUIRE(out == expected);
}
TEST_CASE(__FILE__"/LowerToUpper_Mixed_And_Symbols", "[Char][MakeUpper]")
{
// Setup
const std::string in = "New album 'Cowboy Tears' out February 18! I am excited!";
const std::string expected = "NEW ALBUM 'COWBOY TEARS' OUT FEBRUARY 18! I AM EXCITED!";
// Exercise
std::string out = in;
for (char& c : out)
c = CharTools::MakeUpper(c);
// Verify:
REQUIRE(out == expected);
}

View File

@ -2,7 +2,7 @@
#include "Catch2.h"
// Tests that lowering an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Lower]")
TEST_CASE(__FILE__"/EmptyString", "[Strings][Lower]")
{
// Setup
const std::string in = "";
@ -16,7 +16,7 @@ TEST_CASE(__FILE__"/EmptyString", "[Lower]")
}
// Tests that lowering a string without any letters returns itself
TEST_CASE(__FILE__"/Symbols", "[Lower]")
TEST_CASE(__FILE__"/Symbols", "[Strings][Lower]")
{
// Setup
const std::string in = "66! _-\n*";
@ -30,7 +30,7 @@ TEST_CASE(__FILE__"/Symbols", "[Lower]")
}
// Tests that lowering a string of lowercase letters returns itself
TEST_CASE(__FILE__"/AlreadyLowered", "[Lower]")
TEST_CASE(__FILE__"/AlreadyLowered", "[Strings][Lower]")
{
// Setup
const std::string in = "ughareyouserious";
@ -44,7 +44,7 @@ TEST_CASE(__FILE__"/AlreadyLowered", "[Lower]")
}
// Tests that lowering a string of uppercase letters returns the lowercase version
TEST_CASE(__FILE__"/Uppercase", "[Lower]")
TEST_CASE(__FILE__"/Uppercase", "[Strings][Lower]")
{
// Setup
const std::string in = "UGHAREYOUSERIOUS";
@ -58,7 +58,7 @@ TEST_CASE(__FILE__"/Uppercase", "[Lower]")
}
// Tests that lowering a string of uppercase, lowercase letters and symbols returns the lowercase version
TEST_CASE(__FILE__"/Mixed", "[Lower]")
TEST_CASE(__FILE__"/Mixed", "[Strings][Lower]")
{
// Setup
const std::string in = "Ugh, Are You Serious?! DON'T DO THAT!!!";

View File

@ -2,7 +2,7 @@
#include "Catch2.h"
// Tests that replacing something in an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[ReplaceChar]")
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "";
@ -16,7 +16,7 @@ TEST_CASE(__FILE__"/EmptyString", "[ReplaceChar]")
}
// Tests that replacing a char to an empty string works
TEST_CASE(__FILE__"/Single_ReplaceToEmpty", "[ReplaceChar]")
TEST_CASE(__FILE__"/Single_ReplaceToEmpty", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "i";
@ -30,7 +30,7 @@ TEST_CASE(__FILE__"/Single_ReplaceToEmpty", "[ReplaceChar]")
}
// Tests that replacing to a single char works
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar", "[ReplaceChar]")
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "a";
@ -44,7 +44,7 @@ TEST_CASE(__FILE__"/Single_ReplaceToSingleChar", "[ReplaceChar]")
}
// Tests that replacing to a single char works, passing a char
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar_AsChar", "[ReplaceChar]")
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar_AsChar", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "Oilbanger";
@ -58,7 +58,7 @@ TEST_CASE(__FILE__"/Single_ReplaceToSingleChar_AsChar", "[ReplaceChar]")
}
// Tests that replacing the find to something longer works
TEST_CASE(__FILE__"/Single_ReplaceToLonger", "[ReplaceChar]")
TEST_CASE(__FILE__"/Single_ReplaceToLonger", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "Littled";
@ -72,7 +72,7 @@ TEST_CASE(__FILE__"/Single_ReplaceToLonger", "[ReplaceChar]")
}
// Tests that replacing a char to an empty string works
TEST_CASE(__FILE__"/Multiple_ReplaceToEmpty", "[ReplaceChar]")
TEST_CASE(__FILE__"/Multiple_ReplaceToEmpty", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "dirty dogs dig dirt daringly";
@ -86,7 +86,7 @@ TEST_CASE(__FILE__"/Multiple_ReplaceToEmpty", "[ReplaceChar]")
}
// Tests that replacing to a single char works
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar", "[ReplaceChar]")
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "Oilbanger, Bangerfanger, Lattle brattle oaly skattle.";
@ -100,7 +100,7 @@ TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar", "[ReplaceChar]")
}
// Tests that replacing to a single char works, passing a char
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar_AsChar", "[ReplaceChar]")
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar_AsChar", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "Oilbanger, Bangerfanger, Lattle brattle oaly skattle.";
@ -114,7 +114,7 @@ TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar_AsChar", "[ReplaceChar]")
}
// Tests that replacing the find to something longer works
TEST_CASE(__FILE__"/Multiple_ReplaceToLonger", "[ReplaceChar]")
TEST_CASE(__FILE__"/Multiple_ReplaceToLonger", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "d d d d d d d d";
@ -128,7 +128,7 @@ TEST_CASE(__FILE__"/Multiple_ReplaceToLonger", "[ReplaceChar]")
}
// Tests that the replacer ignores chars put in by the replacer
TEST_CASE(__FILE__"/ReplacerIgnoresReplaced", "[ReplaceChar]")
TEST_CASE(__FILE__"/ReplacerIgnoresReplaced", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "b b b b b b b b";
@ -142,7 +142,7 @@ TEST_CASE(__FILE__"/ReplacerIgnoresReplaced", "[ReplaceChar]")
}
// Tests that replacing succesive findings works
TEST_CASE(__FILE__"/Replace_Successive", "[ReplaceChar]")
TEST_CASE(__FILE__"/Replace_Successive", "[Strings][ReplaceChar]")
{
// Setup
const std::string in = "bbbbbbbb";

View File

@ -2,7 +2,7 @@
#include "Catch2.h"
// Tests that replacing something in an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[ReplaceString]")
TEST_CASE(__FILE__"/EmptyString", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "";
@ -16,7 +16,7 @@ TEST_CASE(__FILE__"/EmptyString", "[ReplaceString]")
}
// Tests that replacing a string to an empty string works
TEST_CASE(__FILE__"/Single_ReplaceToEmpty", "[ReplaceString]")
TEST_CASE(__FILE__"/Single_ReplaceToEmpty", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "Squarepants";
@ -30,7 +30,7 @@ TEST_CASE(__FILE__"/Single_ReplaceToEmpty", "[ReplaceString]")
}
// Tests that replacing to a single char works
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar", "[ReplaceString]")
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "Squarepants";
@ -44,7 +44,7 @@ TEST_CASE(__FILE__"/Single_ReplaceToSingleChar", "[ReplaceString]")
}
// Tests that replacing to a single char works, passing a char
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar_AsChar", "[ReplaceString]")
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar_AsChar", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "Oilbanger";
@ -58,7 +58,7 @@ TEST_CASE(__FILE__"/Single_ReplaceToSingleChar_AsChar", "[ReplaceString]")
}
// Tests that replacing the find to something longer works
TEST_CASE(__FILE__"/Single_ReplaceToLonger", "[ReplaceString]")
TEST_CASE(__FILE__"/Single_ReplaceToLonger", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "LittleDong";
@ -72,7 +72,7 @@ TEST_CASE(__FILE__"/Single_ReplaceToLonger", "[ReplaceString]")
}
// Tests that replacing a string to an empty string works
TEST_CASE(__FILE__"/Multiple_ReplaceToEmpty", "[ReplaceString]")
TEST_CASE(__FILE__"/Multiple_ReplaceToEmpty", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "The fucking dogs are fucking eating the fucking chicken.";
@ -86,7 +86,7 @@ TEST_CASE(__FILE__"/Multiple_ReplaceToEmpty", "[ReplaceString]")
}
// Tests that replacing to a single char works
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar", "[ReplaceString]")
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "Oilbsmearynger, Bsmearyngerfsmearynger, Lsmearyttle brsmearyttle osmearyly sksmearyttle.";
@ -100,7 +100,7 @@ TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar", "[ReplaceString]")
}
// Tests that replacing to a single char works, passing a char
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar_AsChar", "[ReplaceString]")
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar_AsChar", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "Oilbsmearynger, Bsmearyngerfsmearynger, Lsmearyttle brsmearyttle osmearyly sksmearyttle.";
@ -114,7 +114,7 @@ TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar_AsChar", "[ReplaceString]")
}
// Tests that replacing the find to something longer works
TEST_CASE(__FILE__"/Multiple_ReplaceToLonger", "[ReplaceString]")
TEST_CASE(__FILE__"/Multiple_ReplaceToLonger", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "honk honk honk honk honk honk honk honk";
@ -128,7 +128,7 @@ TEST_CASE(__FILE__"/Multiple_ReplaceToLonger", "[ReplaceString]")
}
// Tests that the replacer ignores chars put in by the replacer
TEST_CASE(__FILE__"/ReplacerIgnoresReplaced", "[ReplaceString]")
TEST_CASE(__FILE__"/ReplacerIgnoresReplaced", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "honk honk honk honk honk honk honk honk";
@ -142,7 +142,7 @@ TEST_CASE(__FILE__"/ReplacerIgnoresReplaced", "[ReplaceString]")
}
// Tests that replacing successive findings works
TEST_CASE(__FILE__"/Replace_Successive", "[ReplaceString]")
TEST_CASE(__FILE__"/Replace_Successive", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "honkhonkhonkhonkhonkhonkhonkhonk";
@ -156,7 +156,7 @@ TEST_CASE(__FILE__"/Replace_Successive", "[ReplaceString]")
}
// Tests that if find.length() == 0, it returns just the input
TEST_CASE(__FILE__"/Find_Length0_Returns_Input", "[ReplaceString]")
TEST_CASE(__FILE__"/Find_Length0_Returns_Input", "[Strings][ReplaceString]")
{
// Setup
const std::string in = "Littled";

View File

@ -2,7 +2,7 @@
#include "Catch2.h"
// Tests that uppering an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Upper]")
TEST_CASE(__FILE__"/EmptyString", "[Strings][Upper]")
{
// Setup
const std::string in = "";
@ -16,7 +16,7 @@ TEST_CASE(__FILE__"/EmptyString", "[Upper]")
}
// Tests that uppering a string without any letters returns itself
TEST_CASE(__FILE__"/Symbols", "[Upper]")
TEST_CASE(__FILE__"/Symbols", "[Strings][Upper]")
{
// Setup
const std::string in = "66! _-\n*";
@ -30,7 +30,7 @@ TEST_CASE(__FILE__"/Symbols", "[Upper]")
}
// Tests that uppering a string of uppercase letters returns itself
TEST_CASE(__FILE__"/AlreadyUppered", "[Upper]")
TEST_CASE(__FILE__"/AlreadyUppered", "[Strings][Upper]")
{
// Setup
const std::string in = "UGHAREYOUSERIOUS";
@ -44,7 +44,7 @@ TEST_CASE(__FILE__"/AlreadyUppered", "[Upper]")
}
// Tests that uppering a string of lowercase letters returns the uppercase version
TEST_CASE(__FILE__"/Lowercase", "[Upper]")
TEST_CASE(__FILE__"/Lowercase", "[Strings][Upper]")
{
// Setup
const std::string in = "ughareyouserious";
@ -58,7 +58,7 @@ TEST_CASE(__FILE__"/Lowercase", "[Upper]")
}
// Tests that uppering a string of uppercase, lowercase letters and symbols returns the uppercase version
TEST_CASE(__FILE__"/Mixed", "[Upper]")
TEST_CASE(__FILE__"/Mixed", "[Strings][Upper]")
{
// Setup
const std::string in = "Ugh, Are You Serious?! DON'T do that!!!";