From 3705bcc9bc8c726a60c1eaa1d29cd1d240c0268a Mon Sep 17 00:00:00 2001 From: Evgeniy Filatov Date: Thu, 2 Aug 2018 17:57:16 +0300 Subject: added helper function that joins vectors of strings, refactored suggestions formattingi function to use it --- test/libdevcore/StringUtils.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') 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({})), ""); + BOOST_CHECK_EQUAL(joinHumanReadable(vector({"a"})), "a"); + BOOST_CHECK_EQUAL(joinHumanReadable(vector({"a", "b"})), "a, b"); + BOOST_CHECK_EQUAL(joinHumanReadable(vector({"a", "b", "c"})), "a, b, c"); + + BOOST_CHECK_EQUAL(joinHumanReadable(vector({}), "; "), ""); + BOOST_CHECK_EQUAL(joinHumanReadable(vector({"a"}), "; "), "a"); + BOOST_CHECK_EQUAL(joinHumanReadable(vector({"a", "b"}), "; "), "a; b"); + BOOST_CHECK_EQUAL(joinHumanReadable(vector({"a", "b", "c"}), "; "), "a; b; c"); + + BOOST_CHECK_EQUAL(joinHumanReadable(vector({}), "; ", " or "), ""); + BOOST_CHECK_EQUAL(joinHumanReadable(vector({"a"}), "; ", " or "), "a"); + BOOST_CHECK_EQUAL(joinHumanReadable(vector({"a", "b"}), "; ", " or "), "a or b"); + BOOST_CHECK_EQUAL(joinHumanReadable(vector({"a", "b", "c"}), "; ", " or "), "a; b or c"); +} + BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3