Better directory structure naming

This commit is contained in:
Leonetienne
2022-02-12 03:07:11 +01:00
parent f4e36ec9af
commit a6c9e64eb5
14 changed files with 2 additions and 2 deletions

18
Src/Test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.16)
project(Tests)
set(CMAKE_CXX_STANDARD 17)
include_directories(..)
link_directories(../StringTools/cmake-build-debug)
add_executable(Tests
Catch2.h
main.cpp
Lower.cpp
Upper.cpp
Replace_Char.cpp
Replace_String.cpp
)
target_link_libraries(Tests Stringtools)

17965
Src/Test/Catch2.h Normal file

File diff suppressed because it is too large Load Diff

72
Src/Test/Lower.cpp Normal file
View File

@@ -0,0 +1,72 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
// Tests that lowering an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Lower]")
{
// Setup
const std::string in = "";
// Exercise
const std::string out = StringTools::Lower(in);
// Verify
REQUIRE(out == "");
return;
}
// Tests that lowering a string without any letters returns itself
TEST_CASE(__FILE__"/Symbols", "[Lower]")
{
// Setup
const std::string in = "66! _-\n*";
// Exercise
const std::string out = StringTools::Lower(in);
// Verify
REQUIRE(out == "66! _-\n*");
return;
}
// Tests that lowering a string of lowercase letters returns itself
TEST_CASE(__FILE__"/AlreadyLowered", "[Lower]")
{
// Setup
const std::string in = "ughareyouserious";
// Exercise
const std::string out = StringTools::Lower(in);
// Verify
REQUIRE(out == "ughareyouserious");
return;
}
// Tests that lowering a string of uppercase letters returns the lowercase version
TEST_CASE(__FILE__"/Uppercase", "[Lower]")
{
// Setup
const std::string in = "UGHAREYOUSERIOUS";
// Exercise
const std::string out = StringTools::Lower(in);
// Verify
REQUIRE(out == "ughareyouserious");
return;
}
// Tests that lowering a string of uppercase, lowercase letters and symbols returns the lowercase version
TEST_CASE(__FILE__"/Mixed", "[Lower]")
{
// Setup
const std::string in = "Ugh, Are You Serious?! DON'T DO THAT!!!";
// Exercise
const std::string out = StringTools::Lower(in);
// Verify
REQUIRE(out == "ugh, are you serious?! don't do that!!!");
return;
}

156
Src/Test/Replace_Char.cpp Normal file
View File

@@ -0,0 +1,156 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
// Tests that replacing something in an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[ReplaceChar]")
{
// Setup
const std::string in = "";
// Exercise
const std::string out = StringTools::Replace(in, 'a', "Subst");
// Verify
REQUIRE(out == "");
return;
}
// Tests that replacing a char to an empty string works
TEST_CASE(__FILE__"/Single_ReplaceToEmpty", "[ReplaceChar]")
{
// Setup
const std::string in = "i";
// Exercise
const std::string out = StringTools::Replace(in, 'i', "");
// Verify
REQUIRE(out == "");
return;
}
// Tests that replacing to a single char works
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar", "[ReplaceChar]")
{
// Setup
const std::string in = "a";
// Exercise
const std::string out = StringTools::Replace(in, 'a', "i");
// Verify
REQUIRE(out == "i");
return;
}
// Tests that replacing to a single char works, passing a char
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar_AsChar", "[ReplaceChar]")
{
// Setup
const std::string in = "Oilbanger";
// Exercise
const std::string out = StringTools::Replace(in, 'a', 'i');
// Verify
REQUIRE(out == "Oilbinger");
return;
}
// Tests that replacing the find to something longer works
TEST_CASE(__FILE__"/Single_ReplaceToLonger", "[ReplaceChar]")
{
// Setup
const std::string in = "Littled";
// Exercise
const std::string out = StringTools::Replace(in, 'd', "binger");
// Verify
REQUIRE(out == "Littlebinger");
return;
}
// Tests that replacing a char to an empty string works
TEST_CASE(__FILE__"/Multiple_ReplaceToEmpty", "[ReplaceChar]")
{
// Setup
const std::string in = "dirty dogs dig dirt daringly";
// Exercise
const std::string out = StringTools::Replace(in, 'd', "");
// Verify
REQUIRE(out == "irty ogs ig irt aringly");
return;
}
// Tests that replacing to a single char works
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar", "[ReplaceChar]")
{
// Setup
const std::string in = "Oilbanger, Bangerfanger, Lattle brattle oaly skattle.";
// Exercise
const std::string out = StringTools::Replace(in, 'a', "i");
// Verify
REQUIRE(out == "Oilbinger, Bingerfinger, Little brittle oily skittle.");
return;
}
// Tests that replacing to a single char works, passing a char
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar_AsChar", "[ReplaceChar]")
{
// Setup
const std::string in = "Oilbanger, Bangerfanger, Lattle brattle oaly skattle.";
// Exercise
const std::string out = StringTools::Replace(in, 'a', 'i');
// Verify
REQUIRE(out == "Oilbinger, Bingerfinger, Little brittle oily skittle.");
return;
}
// Tests that replacing the find to something longer works
TEST_CASE(__FILE__"/Multiple_ReplaceToLonger", "[ReplaceChar]")
{
// Setup
const std::string in = "d d d d d d d d";
// Exercise
const std::string out = StringTools::Replace(in, 'd', "bla");
// Verify
REQUIRE(out == "bla bla bla bla bla bla bla bla");
return;
}
// Tests that the replacer ignores chars put in by the replacer
TEST_CASE(__FILE__"/ReplacerIgnoresReplaced", "[ReplaceChar]")
{
// Setup
const std::string in = "b b b b b b b b";
// Exercise
const std::string out = StringTools::Replace(in, 'b', "bla");
// Verify
REQUIRE(out == "bla bla bla bla bla bla bla bla");
return;
}
// Tests that replacing succesive findings works
TEST_CASE(__FILE__"/Replace_Successive", "[ReplaceChar]")
{
// Setup
const std::string in = "bbbbbbbb";
// Exercise
const std::string out = StringTools::Replace(in, 'b', "bla");
// Verify
REQUIRE(out == "blablablablablablablabla");
return;
}

170
Src/Test/Replace_String.cpp Normal file
View File

@@ -0,0 +1,170 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
// Tests that replacing something in an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[ReplaceString]")
{
// Setup
const std::string in = "";
// Exercise
const std::string out = StringTools::Replace(in, "burger", "Subst");
// Verify
REQUIRE(out == "");
return;
}
// Tests that replacing a string to an empty string works
TEST_CASE(__FILE__"/Single_ReplaceToEmpty", "[ReplaceString]")
{
// Setup
const std::string in = "Squarepants";
// Exercise
const std::string out = StringTools::Replace(in, "Squarepants", "");
// Verify
REQUIRE(out == "");
return;
}
// Tests that replacing to a single char works
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar", "[ReplaceString]")
{
// Setup
const std::string in = "Squarepants";
// Exercise
const std::string out = StringTools::Replace(in, "Squarepants", "i");
// Verify
REQUIRE(out == "i");
return;
}
// Tests that replacing to a single char works, passing a char
TEST_CASE(__FILE__"/Single_ReplaceToSingleChar_AsChar", "[ReplaceString]")
{
// Setup
const std::string in = "Oilbanger";
// Exercise
const std::string out = StringTools::Replace(in, "Oilbanger", 'i');
// Verify
REQUIRE(out == "i");
return;
}
// Tests that replacing the find to something longer works
TEST_CASE(__FILE__"/Single_ReplaceToLonger", "[ReplaceString]")
{
// Setup
const std::string in = "LittleDong";
// Exercise
const std::string out = StringTools::Replace(in, "Dong", "Binger");
// Verify
REQUIRE(out == "LittleBinger");
return;
}
// Tests that replacing a string to an empty string works
TEST_CASE(__FILE__"/Multiple_ReplaceToEmpty", "[ReplaceString]")
{
// Setup
const std::string in = "The fucking dogs are fucking eating the fucking chicken.";
// Exercise
const std::string out = StringTools::Replace(in, "fucking ", "");
// Verify
REQUIRE(out == "The dogs are eating the chicken.");
return;
}
// Tests that replacing to a single char works
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar", "[ReplaceString]")
{
// Setup
const std::string in = "Oilbsmearynger, Bsmearyngerfsmearynger, Lsmearyttle brsmearyttle osmearyly sksmearyttle.";
// Exercise
const std::string out = StringTools::Replace(in, "smeary", "i");
// Verify
REQUIRE(out == "Oilbinger, Bingerfinger, Little brittle oily skittle.");
return;
}
// Tests that replacing to a single char works, passing a char
TEST_CASE(__FILE__"/Multiple_ReplaceToSingleChar_AsChar", "[ReplaceString]")
{
// Setup
const std::string in = "Oilbsmearynger, Bsmearyngerfsmearynger, Lsmearyttle brsmearyttle osmearyly sksmearyttle.";
// Exercise
const std::string out = StringTools::Replace(in, "smeary", 'i');
// Verify
REQUIRE(out == "Oilbinger, Bingerfinger, Little brittle oily skittle.");
return;
}
// Tests that replacing the find to something longer works
TEST_CASE(__FILE__"/Multiple_ReplaceToLonger", "[ReplaceString]")
{
// Setup
const std::string in = "honk honk honk honk honk honk honk honk";
// Exercise
const std::string out = StringTools::Replace(in, "honk", "hallery");
// Verify
REQUIRE(out == "hallery hallery hallery hallery hallery hallery hallery hallery");
return;
}
// Tests that the replacer ignores chars put in by the replacer
TEST_CASE(__FILE__"/ReplacerIgnoresReplaced", "[ReplaceString]")
{
// Setup
const std::string in = "honk honk honk honk honk honk honk honk";
// Exercise
const std::string out = StringTools::Replace(in, "honk", "honka");
// Verify
REQUIRE(out == "honka honka honka honka honka honka honka honka");
return;
}
// Tests that replacing successive findings works
TEST_CASE(__FILE__"/Replace_Successive", "[ReplaceString]")
{
// Setup
const std::string in = "honkhonkhonkhonkhonkhonkhonkhonk";
// Exercise
const std::string out = StringTools::Replace(in, "honk", "hallery");
// Verify
REQUIRE(out == "halleryhalleryhalleryhalleryhalleryhalleryhalleryhallery");
return;
}
// Tests that if find.length() == 0, it returns just the input
TEST_CASE(__FILE__"/Find_Length0_Returns_Input", "[ReplaceString]")
{
// Setup
const std::string in = "Littled";
// Exercise
const std::string out = StringTools::Replace(in, "", "binger");
// Verify
REQUIRE(out == "Littled");
return;
}

72
Src/Test/Upper.cpp Normal file
View File

@@ -0,0 +1,72 @@
#include <StringTools/StringTools.h>
#include "Catch2.h"
// Tests that uppering an empty string returns an empty string
TEST_CASE(__FILE__"/EmptyString", "[Upper]")
{
// Setup
const std::string in = "";
// Exercise
const std::string out = StringTools::Upper(in);
// Verify
REQUIRE(out == "");
return;
}
// Tests that uppering a string without any letters returns itself
TEST_CASE(__FILE__"/Symbols", "[Upper]")
{
// Setup
const std::string in = "66! _-\n*";
// Exercise
const std::string out = StringTools::Upper(in);
// Verify
REQUIRE(out == "66! _-\n*");
return;
}
// Tests that uppering a string of uppercase letters returns itself
TEST_CASE(__FILE__"/AlreadyUppered", "[Upper]")
{
// Setup
const std::string in = "UGHAREYOUSERIOUS";
// Exercise
const std::string out = StringTools::Upper(in);
// Verify
REQUIRE(out == "UGHAREYOUSERIOUS");
return;
}
// Tests that uppering a string of lowercase letters returns the uppercase version
TEST_CASE(__FILE__"/Lowercase", "[Upper]")
{
// Setup
const std::string in = "ughareyouserious";
// Exercise
const std::string out = StringTools::Upper(in);
// Verify
REQUIRE(out == "UGHAREYOUSERIOUS");
return;
}
// Tests that uppering a string of uppercase, lowercase letters and symbols returns the uppercase version
TEST_CASE(__FILE__"/Mixed", "[Upper]")
{
// Setup
const std::string in = "Ugh, Are You Serious?! DON'T do that!!!";
// Exercise
const std::string out = StringTools::Upper(in);
// Verify
REQUIRE(out == "UGH, ARE YOU SERIOUS?! DON'T DO THAT!!!");
return;
}

2
Src/Test/main.cpp Normal file
View File

@@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include "Catch2.h"