summaryrefslogtreecommitdiffstats
path: root/Test/Char__IsLetter.cpp
diff options
context:
space:
mode:
authorLeonetienne <leonetienne@hotmail.de>2022-02-12 20:07:48 +0100
committerLeonetienne <leonetienne@hotmail.de>2022-02-12 20:07:48 +0100
commitab1a3672c3392cb2eaf21d020fd09e698e96e255 (patch)
tree51a91ee90a81d58028647adaffc597ffdbca2310 /Test/Char__IsLetter.cpp
parentcf397f3af828bf1f87392a5a1c349284589d25af (diff)
Added tests for char tools
Diffstat (limited to 'Test/Char__IsLetter.cpp')
-rw-r--r--Test/Char__IsLetter.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/Test/Char__IsLetter.cpp b/Test/Char__IsLetter.cpp
new file mode 100644
index 0000000..08f27a6
--- /dev/null
+++ b/Test/Char__IsLetter.cpp
@@ -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.");
+}