diff options
author | Evgeniy Filatov <efilatov@geeksforless.net> | 2018-08-02 22:57:16 +0800 |
---|---|---|
committer | Evgeniy Filatov <efilatov@geeksforless.net> | 2018-08-03 19:07:03 +0800 |
commit | 3705bcc9bc8c726a60c1eaa1d29cd1d240c0268a (patch) | |
tree | 29ab864be99ead58a263cbd67d8ecc4f1a585472 /test/libdevcore/StringUtils.cpp | |
parent | 009a55c82d22f08fd207739d7b8aeff215fb7c03 (diff) | |
download | dexon-solidity-3705bcc9bc8c726a60c1eaa1d29cd1d240c0268a.tar.gz dexon-solidity-3705bcc9bc8c726a60c1eaa1d29cd1d240c0268a.tar.zst dexon-solidity-3705bcc9bc8c726a60c1eaa1d29cd1d240c0268a.zip |
added helper function that joins vectors of strings, refactored suggestions formattingi function to use it
Diffstat (limited to 'test/libdevcore/StringUtils.cpp')
-rw-r--r-- | test/libdevcore/StringUtils.cpp | 18 |
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() |