summaryrefslogtreecommitdiffstats
path: root/StringTools/test/Char__CopySign.cpp
diff options
context:
space:
mode:
authorLeonetienne <leon@etiennes.de>2022-05-16 23:57:26 +0200
committerLeonetienne <leon@etiennes.de>2022-05-16 23:57:26 +0200
commit954629f6bc3b7753c5be0c08e0cdb5caf1056d23 (patch)
tree33a95f60202135f9fcc689e081a64f2d274d7d99 /StringTools/test/Char__CopySign.cpp
parent1fe3eeb14470470d8c95c40c98a12c15320bcd57 (diff)
Adhere to new project structure
Diffstat (limited to 'StringTools/test/Char__CopySign.cpp')
-rw-r--r--StringTools/test/Char__CopySign.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/StringTools/test/Char__CopySign.cpp b/StringTools/test/Char__CopySign.cpp
new file mode 100644
index 0000000..177e718
--- /dev/null
+++ b/StringTools/test/Char__CopySign.cpp
@@ -0,0 +1,69 @@
+#include <StringTools/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);
+}