aboutsummaryrefslogtreecommitdiffstats
path: root/test/libdevcore/StringUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libdevcore/StringUtils.cpp')
-rw-r--r--test/libdevcore/StringUtils.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/libdevcore/StringUtils.cpp b/test/libdevcore/StringUtils.cpp
index 9ee93d02..94f1b753 100644
--- a/test/libdevcore/StringUtils.cpp
+++ b/test/libdevcore/StringUtils.cpp
@@ -81,6 +81,24 @@ BOOST_AUTO_TEST_CASE(test_alternatives_list)
BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "\"a\", \"b\", \"c\" or \"d\"");
}
+BOOST_AUTO_TEST_CASE(test_human_readable_join)
+{
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({})), "");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"})), "a");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"})), "a, b");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"})), "a, b, c");
+
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({}), "; "), "");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"}), "; "), "a");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"}), "; "), "a; b");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"}), "; "), "a; b; c");
+
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({}), "; ", " or "), "");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"}), "; ", " or "), "a");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"}), "; ", " or "), "a or b");
+ BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"}), "; ", " or "), "a; b or c");
+}
+
BOOST_AUTO_TEST_SUITE_END()