summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Albright <eric_albright@sil.org>2007-12-10 06:28:33 +0000
committerEric Albright <eric_albright@sil.org>2007-12-10 06:28:33 +0000
commit52fc8c4204f8c83e5e63c4809edb07e8e108b183 (patch)
treeedd842ca085166749efcce40385b11a3618cc861
parent0d20be5a760553647dbd970a46307877a36055f7 (diff)
downloadenchant-52fc8c4204f8c83e5e63c4809edb07e8e108b183.tar.gz
Additional tests for pwl edit distance
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@22367 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r--unittests/pwl/enchant_pwl_tests.cpp140
1 files changed, 139 insertions, 1 deletions
diff --git a/unittests/pwl/enchant_pwl_tests.cpp b/unittests/pwl/enchant_pwl_tests.cpp
index 44a1595..9d31ca9 100644
--- a/unittests/pwl/enchant_pwl_tests.cpp
+++ b/unittests/pwl/enchant_pwl_tests.cpp
@@ -1033,7 +1033,27 @@ TEST_FIXTURE(EnchantPwl_TestFixture,
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Pwl Edit distance bugs
+// Pwl Edit distance
+TEST_FIXTURE(EnchantPwl_TestFixture,
+ PwlSuggest_HasProperSubset_SubstituteFirstChar)
+{
+ std::vector<const std::string> sWords;
+ sWords.push_back("cat"); //1
+
+ AddWordsToDictionary(sWords);
+
+ AddWordToDictionary("catsup"); //4
+
+ std::vector<const std::string> suggestions = GetSuggestionsFromWord("tat");
+
+ CHECK_EQUAL(sWords.size(), suggestions.size());
+
+ std::sort(sWords.begin(), sWords.end());
+ std::sort(suggestions.begin(), suggestions.end());
+
+ CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));
+}
+
TEST_FIXTURE(EnchantPwl_TestFixture,
PwlSuggest_HasProperSubset_SubstituteFirstChar_Insert1)
{
@@ -1132,3 +1152,121 @@ TEST_FIXTURE(EnchantPwl_TestFixture,
CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));
}
+TEST_FIXTURE(EnchantPwl_TestFixture,
+ PwlSuggest_HasProperSubset_Delete1)
+{
+ std::vector<const std::string> sWords;
+ sWords.push_back("tape"); //1
+
+ AddWordsToDictionary(sWords);
+
+ AddWordToDictionary("tapestry"); //4
+
+ std::vector<const std::string> suggestions = GetSuggestionsFromWord("tapen");
+
+ CHECK_EQUAL(sWords.size(), suggestions.size());
+
+ std::sort(sWords.begin(), sWords.end());
+ std::sort(suggestions.begin(), suggestions.end());
+
+ CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));
+}
+
+TEST_FIXTURE(EnchantPwl_TestFixture,
+ PwlSuggest_HasProperSubset_Delete2)
+{
+ std::vector<const std::string> sWords;
+ sWords.push_back("tot"); //2
+
+ AddWordsToDictionary(sWords);
+
+ AddWordToDictionary("totality"); //4
+
+ std::vector<const std::string> suggestions = GetSuggestionsFromWord("totil");
+
+ CHECK_EQUAL(sWords.size(), suggestions.size());
+
+ std::sort(sWords.begin(), sWords.end());
+ std::sort(suggestions.begin(), suggestions.end());
+
+ CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));
+}
+TEST_FIXTURE(EnchantPwl_TestFixture,
+ PwlSuggest_HasProperSubset_Delete3)
+{
+ std::vector<const std::string> sWords;
+ sWords.push_back("cat"); //3
+
+ AddWordsToDictionary(sWords);
+
+ AddWordToDictionary("catcher"); //4
+
+ std::vector<const std::string> suggestions = GetSuggestionsFromWord("catsip");
+
+ CHECK_EQUAL(sWords.size(), suggestions.size());
+
+ std::sort(sWords.begin(), sWords.end());
+ std::sort(suggestions.begin(), suggestions.end());
+
+ CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));
+}
+
+TEST_FIXTURE(EnchantPwl_TestFixture,
+ PwlSuggest_HasProperSubset_Substitute1)
+{
+ std::vector<const std::string> sWords;
+ sWords.push_back("small"); //1
+
+ AddWordsToDictionary(sWords);
+
+ AddWordToDictionary("smallest"); //4
+
+ std::vector<const std::string> suggestions = GetSuggestionsFromWord("skall");
+
+ CHECK_EQUAL(sWords.size(), suggestions.size());
+
+ std::sort(sWords.begin(), sWords.end());
+ std::sort(suggestions.begin(), suggestions.end());
+
+ CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));
+}
+
+TEST_FIXTURE(EnchantPwl_TestFixture,
+ PwlSuggest_HasProperSubset_Substitute2)
+{
+ std::vector<const std::string> sWords;
+ sWords.push_back("catch"); //2
+
+ AddWordsToDictionary(sWords);
+
+ AddWordToDictionary("catcher"); //4
+
+ std::vector<const std::string> suggestions = GetSuggestionsFromWord("cafdh");
+
+ CHECK_EQUAL(sWords.size(), suggestions.size());
+
+ std::sort(sWords.begin(), sWords.end());
+ std::sort(suggestions.begin(), suggestions.end());
+
+ CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));
+}
+
+TEST_FIXTURE(EnchantPwl_TestFixture,
+ PwlSuggest_HasProperSubset_Substitute3)
+{
+ std::vector<const std::string> sWords;
+ sWords.push_back("hasten"); //3
+
+ AddWordsToDictionary(sWords);
+
+ AddWordToDictionary("hastens"); //4
+
+ std::vector<const std::string> suggestions = GetSuggestionsFromWord("hasopo");
+
+ CHECK_EQUAL(sWords.size(), suggestions.size());
+
+ std::sort(sWords.begin(), sWords.end());
+ std::sort(suggestions.begin(), suggestions.end());
+
+ CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));
+}