From ab1a3672c3392cb2eaf21d020fd09e698e96e255 Mon Sep 17 00:00:00 2001 From: Leonetienne Date: Sat, 12 Feb 2022 20:07:48 +0100 Subject: Added tests for char tools --- Test/Char__CopySign.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Test/Char__CopySign.cpp (limited to 'Test/Char__CopySign.cpp') diff --git a/Test/Char__CopySign.cpp b/Test/Char__CopySign.cpp new file mode 100644 index 0000000..b205575 --- /dev/null +++ b/Test/Char__CopySign.cpp @@ -0,0 +1,69 @@ +#include +#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); +} \ No newline at end of file -- cgit v1.2.3