aboutsummaryrefslogtreecommitdiff
path: root/src/test/util_tests.cpp
diff options
context:
space:
mode:
author251 <13120787+251Labs@users.noreply.github.com>2018-08-28 18:42:27 +0200
committer251 <13120787+251Labs@users.noreply.github.com>2018-08-28 18:42:27 +0200
commit7a208d9fade56e2347891daff2f6b903923c9d50 (patch)
tree575ae31e45b1069110bd344f0eb27d8ee8ef6ddb /src/test/util_tests.cpp
parente2ba043b8d852d3f465bc293d6e494c8c6f75dfd (diff)
Implements custom tolower and toupper functions.
This commit implements custom equivalents for the C and C++ `tolower` and `toupper` Standard Library functions. In addition it implements a utility function to capitalize the first letter of a string.
Diffstat (limited to 'src/test/util_tests.cpp')
-rw-r--r--src/test/util_tests.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index b2960446eb..8e2f5abe66 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -1217,4 +1217,43 @@ BOOST_AUTO_TEST_CASE(test_DirIsWritable)
fs::remove(tmpdirname);
}
+BOOST_AUTO_TEST_CASE(test_ToLower)
+{
+ BOOST_CHECK_EQUAL(ToLower('@'), '@');
+ BOOST_CHECK_EQUAL(ToLower('A'), 'a');
+ BOOST_CHECK_EQUAL(ToLower('Z'), 'z');
+ BOOST_CHECK_EQUAL(ToLower('['), '[');
+ BOOST_CHECK_EQUAL(ToLower(0), 0);
+ BOOST_CHECK_EQUAL(ToLower(255), 255);
+
+ std::string testVector;
+ Downcase(testVector);
+ BOOST_CHECK_EQUAL(testVector, "");
+
+ testVector = "#HODL";
+ Downcase(testVector);
+ BOOST_CHECK_EQUAL(testVector, "#hodl");
+
+ testVector = "\x00\xfe\xff";
+ Downcase(testVector);
+ BOOST_CHECK_EQUAL(testVector, "\x00\xfe\xff");
+}
+
+BOOST_AUTO_TEST_CASE(test_ToUpper)
+{
+ BOOST_CHECK_EQUAL(ToUpper('`'), '`');
+ BOOST_CHECK_EQUAL(ToUpper('a'), 'A');
+ BOOST_CHECK_EQUAL(ToUpper('z'), 'Z');
+ BOOST_CHECK_EQUAL(ToUpper('{'), '{');
+ BOOST_CHECK_EQUAL(ToUpper(0), 0);
+ BOOST_CHECK_EQUAL(ToUpper(255), 255);
+}
+
+BOOST_AUTO_TEST_CASE(test_Capitalize)
+{
+ BOOST_CHECK_EQUAL(Capitalize(""), "");
+ BOOST_CHECK_EQUAL(Capitalize("bitcoin"), "Bitcoin");
+ BOOST_CHECK_EQUAL(Capitalize("\x00\xfe\xff"), "\x00\xfe\xff");
+}
+
BOOST_AUTO_TEST_SUITE_END()