aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBalajiganapathi S <balajiganapathi.s@gmail.com>2017-11-22 00:50:35 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-02-13 23:00:15 +0800
commit8a491c77ba9680afdf8c33664e905b978152b095 (patch)
tree04eb2325c2a6e20d6a21ef0d9fe64efc1629d9a6 /test
parentd123e777d33be3134ebbcda969f149e0e7ad0b0f (diff)
downloaddexon-solidity-8a491c77ba9680afdf8c33664e905b978152b095.tar.gz
dexon-solidity-8a491c77ba9680afdf8c33664e905b978152b095.tar.zst
dexon-solidity-8a491c77ba9680afdf8c33664e905b978152b095.zip
Restructure code for alternative identifier suggestions
Diffstat (limited to 'test')
-rw-r--r--test/libdevcore/StringUtils.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/libdevcore/StringUtils.cpp b/test/libdevcore/StringUtils.cpp
index 7a5fe26e..597457cc 100644
--- a/test/libdevcore/StringUtils.cpp
+++ b/test/libdevcore/StringUtils.cpp
@@ -50,6 +50,38 @@ BOOST_AUTO_TEST_CASE(test_similarity)
BOOST_CHECK_EQUAL(stringWithinDistance("", "", 2), true);
}
+BOOST_AUTO_TEST_CASE(test_dldistance)
+{
+ BOOST_CHECK_EQUAL(stringDistance("hello", "hellw"), 1);
+ BOOST_CHECK_EQUAL(stringDistance("hello", "helol"), 1);
+ BOOST_CHECK_EQUAL(stringDistance("hello", "helo"), 1);
+ BOOST_CHECK_EQUAL(stringDistance("hello", "helllo"), 1);
+ BOOST_CHECK_EQUAL(stringDistance("hello", "hlllo"), 1);
+ BOOST_CHECK_EQUAL(stringDistance("hello", "hllllo"), 2);
+ BOOST_CHECK_EQUAL(stringDistance("a", ""), 1);
+ BOOST_CHECK_EQUAL(stringDistance("abc", "ba"), 2);
+ BOOST_CHECK_EQUAL(stringDistance("abc", "abcdef"), 3);
+ BOOST_CHECK_EQUAL(stringDistance("abcd", "wxyz"), 4);
+ BOOST_CHECK_EQUAL(stringDistance("", ""), 0);
+ BOOST_CHECK_EQUAL(stringDistance("abcdefghijklmnopqrstuvwxyz", "abcabcabcabcabcabcabcabca"), 23);
+
+}
+
+BOOST_AUTO_TEST_CASE(test_alternatives_list)
+{
+ vector<string> strings;
+ BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "");
+ strings.push_back("a");
+ BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "\"a\"");
+ strings.push_back("b");
+ BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "\"a\" or \"b\"");
+ strings.push_back("c");
+ BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "\"a\", \"b\" or \"c\"");
+ strings.push_back("d");
+ BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "\"a\", \"b\", \"c\" or \"d\"");
+}
+
+
BOOST_AUTO_TEST_SUITE_END()
}