Tizen 2.1 base
[external/enchant.git] / unittests / pwl / enchant_pwl_tests.cpp
1 /* Copyright (c) 2007 Eric Scott Albright\r
2  * \r
3  * Permission is hereby granted, free of charge, to any person obtaining a copy\r
4  * of this software and associated documentation files (the "Software"), to deal\r
5  * in the Software without restriction, including without limitation the rights\r
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
7  * copies of the Software, and to permit persons to whom the Software is\r
8  * furnished to do so, subject to the following conditions:\r
9  * \r
10  * The above copyright notice and this permission notice shall be included in\r
11  * all copies or substantial portions of the Software.\r
12  * \r
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
19  * THE SOFTWARE.\r
20  */\r
21 #define NOMINMAX //don't want windows to collide with std::min\r
22 #include <UnitTest++.h>\r
23 #include <enchant.h>\r
24 #include <enchant-provider.h>\r
25 \r
26 #include "../EnchantDictionaryTestFixture.h"\r
27 \r
28 #include <algorithm>\r
29 \r
30 static char **\r
31 DictionarySuggestsSat (EnchantDict * dict, const char *const word, size_t len, size_t * out_n_suggs)\r
32 {\r
33     *out_n_suggs = 1;\r
34     char **sugg_arr = NULL;\r
35 \r
36     sugg_arr = g_new0 (char *, *out_n_suggs + 1);\r
37     sugg_arr[0] = g_strdup ("sat");\r
38 \r
39     return sugg_arr;\r
40 }\r
41 \r
42 static EnchantDict* MockProviderRequestSuggestMockDictionary(EnchantProvider * me, const char *tag)\r
43 {\r
44     \r
45     EnchantDict* dict = MockProviderRequestEmptyMockDictionary(me, tag);\r
46     dict->suggest = DictionarySuggestsSat;\r
47     return dict;\r
48 }\r
49 \r
50 static void DictionarySuggest_ProviderConfiguration (EnchantProvider * me, const char *)\r
51 {\r
52      me->request_dict = MockProviderRequestSuggestMockDictionary;\r
53      me->dispose_dict = MockProviderDisposeDictionary;\r
54      me->free_string_list = MockProviderFreeStringList;\r
55 }\r
56 \r
57 \r
58 struct EnchantPwlWithDictSuggs_TestFixture : EnchantDictionaryTestFixture\r
59 {\r
60     EnchantPwlWithDictSuggs_TestFixture(const std::string& languageTag="qaa"):\r
61         EnchantDictionaryTestFixture(DictionarySuggest_ProviderConfiguration, languageTag)\r
62     { }\r
63 };\r
64 \r
65 struct EnchantPwl_TestFixture : EnchantDictionaryTestFixture\r
66 {\r
67     //Setup\r
68     EnchantPwl_TestFixture(const std::string& languageTag="qaa"):\r
69         EnchantDictionaryTestFixture(EmptyDictionary_ProviderConfiguration, languageTag)\r
70     { }\r
71 };\r
72 \r
73 TEST_FIXTURE(EnchantPwl_TestFixture, \r
74              GetSuggestionsFromWord_MultipleSuggestions_ReturnsOnlyClosest)\r
75 {\r
76   std::vector<const std::string> sNoiseWords;\r
77   sNoiseWords.push_back("spat");\r
78   sNoiseWords.push_back("tots");\r
79   sNoiseWords.push_back("tater");\r
80   sNoiseWords.push_back("ton");\r
81   sNoiseWords.push_back("gnat");\r
82 \r
83   std::vector<const std::string> sWords;\r
84   sWords.push_back("cat");\r
85   sWords.push_back("hat");\r
86   sWords.push_back("that");\r
87   sWords.push_back("bat");\r
88   sWords.push_back("tot");\r
89 \r
90   AddWordsToDictionary(sWords);\r
91   AddWordsToDictionary(sNoiseWords);\r
92 \r
93   std::vector<const std::string> suggestions = GetSuggestionsFromWord("tat");\r
94   CHECK_EQUAL(sWords.size(), suggestions.size());\r
95   \r
96   std::sort(sWords.begin(), sWords.end());\r
97   std::sort(suggestions.begin(), suggestions.end());\r
98 \r
99   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
100 }\r
101 \r
102 TEST_FIXTURE(EnchantPwlWithDictSuggs_TestFixture,\r
103              GetSuggestionsFromWord_MultipleSuggestions_ReturnsOnlyAsCloseAsDict)\r
104 {\r
105   std::vector<const std::string> sNoiseWords;\r
106   sNoiseWords.push_back("spat");\r
107   sNoiseWords.push_back("tots");\r
108   sNoiseWords.push_back("tater");\r
109   sNoiseWords.push_back("ton");\r
110   sNoiseWords.push_back("gnat");\r
111 \r
112   std::vector<const std::string> sWords;\r
113   sWords.push_back("cat");\r
114   sWords.push_back("hat");\r
115   sWords.push_back("that");\r
116   sWords.push_back("bat");\r
117   sWords.push_back("tot");\r
118 \r
119   AddWordsToDictionary(sWords);\r
120   AddWordsToDictionary(sNoiseWords);\r
121 \r
122   std::vector<const std::string> suggestions = GetSuggestionsFromWord("tat");\r
123   sWords.push_back("sat");\r
124   CHECK_EQUAL(sWords.size(), suggestions.size());\r
125 \r
126   std::sort(sWords.begin(), sWords.end());\r
127   std::sort(suggestions.begin(), suggestions.end());\r
128 \r
129   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
130 }\r
131 \r
132 /////////////////////////////////////////////////////////////////////////////////////////////////\r
133 // External File change\r
134 TEST_FIXTURE(EnchantPwl_TestFixture, \r
135              IsWordInDictionary_DictionaryChangedExternally_Successful)\r
136 {\r
137   std::vector<const std::string> sWords;\r
138   sWords.push_back("cat");\r
139   sWords.push_back("hat");\r
140   sWords.push_back("that");\r
141   sWords.push_back("bat");\r
142   sWords.push_back("tot");\r
143 \r
144   ExternalAddWordsToDictionary(sWords);\r
145 \r
146   for(std::vector<const std::string>::const_iterator itWord = sWords.begin(); itWord != sWords.end(); ++itWord){\r
147     CHECK( IsWordInDictionary(*itWord) );\r
148   }\r
149 \r
150   std::vector<const std::string> sNewWords;\r
151   sNewWords.push_back("potatoe");\r
152   sNewWords.push_back("grow");\r
153   sNewWords.push_back("another");\r
154 \r
155   ExternalAddNewLineToDictionary();\r
156   ExternalAddWordsToDictionary(sNewWords);\r
157 \r
158   for(std::vector<const std::string>::const_iterator itWord = sNewWords.begin(); itWord != sNewWords.end(); ++itWord){\r
159     CHECK( IsWordInDictionary(*itWord) );\r
160     if(!IsWordInDictionary(*itWord)){\r
161          testResults_.OnTestFailure(UnitTest::TestDetails(m_details, __LINE__), itWord->c_str());\r
162     }\r
163   }\r
164 }\r
165 \r
166 TEST_FIXTURE(EnchantPwl_TestFixture, \r
167              Suggest_DictionaryChangedExternally_Successful)\r
168 {\r
169   std::vector<const std::string> sWords;\r
170   sWords.push_back("cat");\r
171   sWords.push_back("hat");\r
172   sWords.push_back("that");\r
173   sWords.push_back("bat");\r
174   sWords.push_back("tot");\r
175 \r
176   ExternalAddWordsToDictionary(sWords);\r
177 \r
178   std::vector<const std::string> suggestions = GetSuggestionsFromWord("tat");\r
179 \r
180   CHECK_EQUAL(sWords.size(), suggestions.size());\r
181 \r
182   std::sort(sWords.begin(), sWords.end());\r
183   std::sort(suggestions.begin(), suggestions.end());\r
184 \r
185   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
186 }\r
187 \r
188 \r
189 /////////////////////////////////////////////////////////////////////////////////////////////////\r
190 // DictionaryBeginsWithBOM\r
191 TEST_FIXTURE(EnchantPwl_TestFixture, \r
192              IsWordInDictionary_DictionaryBeginsWithBOM_Successful)\r
193 {\r
194         char* Utf8Bom = "\xef\xbb\xbf";\r
195 \r
196     Sleep(1000); // FAT systems have a 2 second resolution\r
197                  // NTFS is appreciably faster but no specs on what it is exactly\r
198                  // c runtime library's time_t has a 1 second resolution\r
199     FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "at");\r
200         if(f)\r
201         {\r
202                 fputs(Utf8Bom, f);\r
203         fputs("cat", f);\r
204                 fclose(f);\r
205         }\r
206 \r
207 \r
208   ReloadTestDictionary();\r
209 \r
210     CHECK( IsWordInDictionary("cat") );\r
211 }\r
212 \r
213 /////////////////////////////////////////////////////////////////////////////////////////////////\r
214 // DictionaryHasInvalidUtf8\r
215 TEST_FIXTURE(EnchantPwl_TestFixture, \r
216              IsWordInDictionary_DictionaryHasInvalidUtf8Data_OnlyReadsValidLines)\r
217 {\r
218   std::vector<const std::string> sWords;\r
219   sWords.push_back("cat");\r
220   sWords.push_back("hat");\r
221   sWords.push_back("that");\r
222   sWords.push_back("bat");\r
223   sWords.push_back("tot");\r
224 \r
225   std::vector<const std::string>::const_iterator bad = sWords.insert(sWords.begin()+2, "\xa5\xf1\x08"); //invalid utf8 data\r
226   ExternalAddWordsToDictionary(sWords);\r
227 \r
228   ReloadTestDictionary();\r
229 \r
230   for(std::vector<const std::string>::const_iterator itWord = sWords.begin(); itWord != bad; ++itWord){\r
231     CHECK( IsWordInDictionary(*itWord) );\r
232   }\r
233   CHECK(!IsWordInDictionary(*bad) );\r
234 \r
235   for(std::vector<const std::string>::const_iterator itWord = bad+1; itWord != sWords.end(); ++itWord){\r
236     CHECK(IsWordInDictionary(*itWord) );\r
237   }\r
238 }\r
239 \r
240 /////////////////////////////////////////////////////////////////////////////////////////////////\r
241 // Last word in Dictionary terminated By EOF instead of NL\r
242 TEST_FIXTURE(EnchantPwl_TestFixture, \r
243              IsWordInDictionary_LastWordNotTerminatedByNL_WordsAppendedOkay)\r
244 {\r
245     std::vector<const std::string> sWords;\r
246     sWords.push_back("cat");\r
247     sWords.push_back("hat");\r
248     sWords.push_back("that");\r
249     sWords.push_back("bat");\r
250     sWords.push_back("tot");\r
251 \r
252     Sleep(1000); // FAT systems have a 2 second resolution\r
253                  // NTFS is appreciably faster but no specs on what it is exactly\r
254                  // c runtime library's time_t has a 1 second resolution\r
255     FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "at");\r
256     if(f)\r
257     {\r
258             fputs(sWords[0].c_str(), f);\r
259             fclose(f);\r
260     }\r
261 \r
262     for(std::vector<const std::string>::const_iterator itWord = sWords.begin() +1;\r
263         itWord != sWords.end();\r
264         ++itWord)\r
265     {\r
266         AddWordToDictionary(*itWord);\r
267     }\r
268 \r
269     for(std::vector<const std::string>::const_iterator itWord = sWords.begin(); \r
270         itWord != sWords.end(); \r
271         ++itWord){\r
272         CHECK( IsWordInDictionary(*itWord) );\r
273     }\r
274 }\r
275 \r
276 ////////////////////////////////////////////////////////////////////////////////////////////////\r
277 // Pwl Bugs\r
278 TEST_FIXTURE(EnchantPwl_TestFixture, \r
279              GetSuggestions_DistanceUsesUnicodeChar)\r
280 {\r
281         std::string puaWord("\xF4\x80\x80\x80ord"); // private use character \r
282         AddWordToDictionary(puaWord); //edit distance 1 using unichar; 4 using utf8\r
283 \r
284     std::vector<const std::string> suggestions = GetSuggestionsFromWord("word");\r
285 \r
286         CHECK( !suggestions.empty());\r
287 \r
288         if(!suggestions.empty()){\r
289                 CHECK_EQUAL(puaWord, suggestions[0]);\r
290         }\r
291 }\r
292 \r
293 // Word which is prefix of another gets edit distance which is one less. \r
294 // This means it moves to the top of the list normally but once we only bring\r
295 // back the best matches, it means the rest of the mathes aren't returned\r
296 TEST_FIXTURE(EnchantPwl_TestFixture, \r
297              PwlSuggest_EditDistanceOnWordWhichIsPrefixOfAnother)\r
298 {\r
299   std::vector<const std::string> sNoiseWords;\r
300   sNoiseWords.push_back("hastens"); //4\r
301 \r
302   std::vector<const std::string> sWords;\r
303   sWords.push_back("cashes"); //3\r
304   sWords.push_back("hasten"); //3\r
305   sWords.push_back("washes"); //3\r
306 \r
307   AddWordsToDictionary(sWords);\r
308   AddWordsToDictionary(sNoiseWords);\r
309 \r
310   std::vector<const std::string> suggestions = GetSuggestionsFromWord("saskep");\r
311   CHECK(suggestions[0] != "hasten");\r
312   CHECK_EQUAL(sWords.size(), suggestions.size());\r
313 \r
314   std::sort(sWords.begin(), sWords.end());\r
315   std::sort(suggestions.begin(), suggestions.end());\r
316 \r
317   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
318 }\r
319 \r
320 \r
321 /////////////////////////////////////////////////////////////////////////////////////////////////\r
322 // Commented Lines ignored\r
323 TEST_FIXTURE(EnchantPwl_TestFixture, \r
324              IsWordInDictionary_DictionaryHasCommentedLines_DoesNotReadCommentedLines)\r
325 {\r
326   std::vector<const std::string> sWords;\r
327   sWords.push_back("cat");\r
328   sWords.push_back("hat");\r
329   sWords.push_back("that");\r
330   sWords.push_back("bat");\r
331   sWords.push_back("tot");\r
332 \r
333   std::vector<const std::string>::const_iterator comment = sWords.insert(sWords.begin()+2, "#sat"); //comment\r
334   ExternalAddWordsToDictionary(sWords);\r
335   ReloadTestDictionary();\r
336 \r
337   for(std::vector<const std::string>::const_iterator itWord = sWords.begin(); itWord != comment; ++itWord){\r
338     CHECK( IsWordInDictionary(*itWord) );\r
339   }\r
340 \r
341   CHECK(!IsWordInDictionary(*comment) );\r
342   CHECK(!IsWordInDictionary("sat") );\r
343 \r
344   for(std::vector<const std::string>::const_iterator itWord = comment+1; itWord != sWords.end(); ++itWord){\r
345     CHECK(IsWordInDictionary(*itWord) );\r
346   }\r
347 }\r
348 \r
349 /////////////////////////////////////////////////////////////////////////////////////////////////\r
350 // Too long lines ignored\r
351 TEST_FIXTURE(EnchantPwl_TestFixture, \r
352              IsWordInDictionary_DictionaryHasSuperLongLine_DoesNotReadLine)\r
353 {\r
354     const size_t lineLen = 2048;\r
355 \r
356   std::vector<const std::string> sWords;\r
357   sWords.push_back("cat");\r
358   sWords.push_back("hat");\r
359   sWords.push_back("that");\r
360   sWords.push_back("bat");\r
361   sWords.push_back("tot");\r
362 \r
363   std::vector<const std::string>::const_iterator superlong = sWords.insert(sWords.begin()+2, std::string(lineLen, 'c')); //super long line\r
364   ExternalAddWordsToDictionary(sWords);\r
365   ReloadTestDictionary();\r
366 \r
367   for(std::vector<const std::string>::const_iterator itWord = sWords.begin(); itWord != superlong; ++itWord){\r
368     CHECK( IsWordInDictionary(*itWord) );\r
369   }\r
370 \r
371   CHECK(!IsWordInDictionary(*superlong) );\r
372   for(size_t i=0; i != lineLen; ++i)\r
373   {\r
374       CHECK(!IsWordInDictionary(std::string(i, 'c')) );\r
375   }\r
376 \r
377   for(std::vector<const std::string>::const_iterator itWord = superlong+1; itWord != sWords.end(); ++itWord){\r
378     CHECK(IsWordInDictionary(*itWord) );\r
379   }\r
380 }\r
381 \r
382 /////////////////////////////////////////////////////////////////////////////////////////////////\r
383 // Unicode normalization\r
384 TEST_FIXTURE(EnchantPwl_TestFixture, \r
385              IsWordInDictionary_DictionaryHasComposed_SuccessfulCheckWithComposedAndDecomposed)\r
386 {\r
387   ExternalAddWordToDictionary(Convert(L"fianc\xe9")); // u00e9 = Latin small letter e with acute\r
388 \r
389   ReloadTestDictionary();\r
390 \r
391   CHECK( IsWordInDictionary(Convert(L"fianc\xe9")) ); //NFC\r
392   CHECK( IsWordInDictionary(Convert(L"fiance\x301")) ); //NFD u0301 = Combining acute accent\r
393 }\r
394 \r
395 TEST_FIXTURE(EnchantPwl_TestFixture, \r
396              IsWordInDictionary_AddedComposed_SuccessfulCheckWithComposedAndDecomposed)\r
397 {\r
398   AddWordToDictionary(Convert(L"fianc\xe9")); // u00e9 = Latin small letter e with acute\r
399 \r
400   CHECK( IsWordInDictionary(Convert(L"fianc\xe9")) ); //NFC\r
401   CHECK( IsWordInDictionary(Convert(L"fiance\x301")) ); //NFD u0301 = Combining acute accent\r
402 }\r
403 \r
404 TEST_FIXTURE(EnchantPwl_TestFixture, \r
405              IsWordInDictionary_DictionaryHasDecomposed_SuccessfulCheckWithComposedAndDecomposed)\r
406 {\r
407   ExternalAddWordToDictionary(Convert(L"fiance\x301")); // u0301 = Combining acute accent\r
408 \r
409   ReloadTestDictionary();\r
410 \r
411   CHECK( IsWordInDictionary(Convert(L"fianc\xe9")) ); //NFC\r
412   CHECK( IsWordInDictionary(Convert(L"fiance\x301")) ); //NFD\r
413 }\r
414 \r
415 TEST_FIXTURE(EnchantPwl_TestFixture, \r
416              IsWordInDictionary_AddedDecomposed_SuccessfulCheckWithComposedAndDecomposed)\r
417 {\r
418   AddWordToDictionary(Convert(L"fiance\x301")); // u0301 = Combining acute accent\r
419 \r
420   CHECK( IsWordInDictionary(Convert(L"fianc\xe9")) ); //NFC\r
421   CHECK( IsWordInDictionary(Convert(L"fiance\x301")) ); //NFD\r
422 }\r
423 \r
424 TEST_FIXTURE(EnchantPwl_TestFixture, \r
425              Suggest_DictionaryHasComposed_ReturnsComposed)\r
426 {\r
427   ExternalAddWordToDictionary(Convert(L"fianc\xe9")); // u00e9 = Latin small letter e with acute\r
428 \r
429   ReloadTestDictionary();\r
430 \r
431   std::vector<const std::string> suggestions = GetSuggestionsFromWord("fiance");\r
432 \r
433   std::vector<const std::string> expected;\r
434   expected.push_back(Convert(L"fianc\xe9")); // u00e9 = Latin small letter e with acute\r
435   CHECK_EQUAL(expected.size(), suggestions.size());\r
436   if(expected.size() == suggestions.size())\r
437   {\r
438       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
439   }\r
440 }\r
441 \r
442 TEST_FIXTURE(EnchantPwl_TestFixture, \r
443              Suggest_AddedComposed_ReturnsComposed)\r
444 {\r
445   AddWordToDictionary(Convert(L"fianc\xe9")); // u00e9 = Latin small letter e with acute\r
446 \r
447   std::vector<const std::string> suggestions = GetSuggestionsFromWord("fiance");\r
448 \r
449   std::vector<const std::string> expected;\r
450   expected.push_back(Convert(L"fianc\xe9")); // u00e9 = Latin small letter e with acute\r
451   CHECK_EQUAL(expected.size(), suggestions.size());\r
452   if(expected.size() == suggestions.size())\r
453   {\r
454       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
455   }\r
456 }\r
457 \r
458 TEST_FIXTURE(EnchantPwl_TestFixture, \r
459              Suggest_DictionaryHasDecomposed_ReturnsDecomposed)\r
460 {\r
461   ExternalAddWordToDictionary(Convert(L"fiance\x301")); // u0301 = Combining acute accent\r
462 \r
463   ReloadTestDictionary();\r
464 \r
465   std::vector<const std::string> suggestions = GetSuggestionsFromWord("fiance");\r
466 \r
467   std::vector<const std::string> expected;\r
468   expected.push_back(Convert(L"fiance\x301"));  // u0301 = Combining acute accent\r
469   CHECK_EQUAL(expected.size(), suggestions.size());\r
470   if(expected.size() == suggestions.size())\r
471   {\r
472       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
473   }\r
474 }\r
475 \r
476 TEST_FIXTURE(EnchantPwl_TestFixture, \r
477              Suggest_AddedDecomposed_ReturnsDecomposed)\r
478 {\r
479   AddWordToDictionary(Convert(L"fiance\x301")); // u0301 = Combining acute accent\r
480 \r
481   std::vector<const std::string> suggestions = GetSuggestionsFromWord("fiance");\r
482 \r
483   std::vector<const std::string> expected;\r
484   expected.push_back(Convert(L"fiance\x301")); // u0301 = Combining acute accent\r
485   CHECK_EQUAL(expected.size(), suggestions.size());\r
486   if(expected.size() == suggestions.size())\r
487   {\r
488       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
489   }\r
490 }\r
491   \r
492 /////////////////////////////////////////////////////////////////////////////////////////////////\r
493 // Capitalization\r
494 TEST_FIXTURE(EnchantPwl_TestFixture, \r
495              IsWordInDictionary_AddedAllCaps_OnlyAllCapsSuccessful)\r
496 {\r
497   AddWordToDictionary("CIA");\r
498 \r
499   CHECK( IsWordInDictionary("CIA") );\r
500   CHECK(!IsWordInDictionary("CIa") );\r
501   CHECK(!IsWordInDictionary("Cia") );\r
502   CHECK(!IsWordInDictionary("cia") );\r
503   CHECK(!IsWordInDictionary("cIa") );\r
504 \r
505   CHECK( IsWordInSession("CIA") );\r
506   CHECK(!IsWordInSession("CIa") );\r
507   CHECK(!IsWordInSession("Cia") );\r
508   CHECK(!IsWordInSession("cia") );\r
509   CHECK(!IsWordInSession("cIa") );\r
510 }\r
511 \r
512 TEST_FIXTURE(EnchantPwl_TestFixture, \r
513              IsWordInDictionary_AddedTitle_lowerCaseAndMixedCaseNotSuccessful)\r
514 {\r
515   AddWordToDictionary("Eric");\r
516 \r
517   CHECK( IsWordInDictionary("ERIC") );\r
518   CHECK(!IsWordInDictionary("ERic") );\r
519   CHECK( IsWordInDictionary("Eric") );\r
520   CHECK(!IsWordInDictionary("eric") );\r
521   CHECK(!IsWordInDictionary("eRic") );\r
522 \r
523   CHECK( IsWordInSession("ERIC") );\r
524   CHECK(!IsWordInSession("ERic") );\r
525   CHECK( IsWordInSession("Eric") );\r
526   CHECK(!IsWordInSession("eric") );\r
527   CHECK(!IsWordInSession("eRic") );\r
528 }\r
529 \r
530 TEST_FIXTURE(EnchantPwl_TestFixture, \r
531              IsWordInDictionary_Addedlower_MixedCaseNotSuccessful)\r
532 {\r
533   AddWordToDictionary("rice");\r
534 \r
535   CHECK( IsWordInDictionary("RICE") );\r
536   CHECK(!IsWordInDictionary("RIce") );\r
537   CHECK( IsWordInDictionary("Rice") );\r
538   CHECK( IsWordInDictionary("rice") );\r
539   CHECK(!IsWordInDictionary("rIce") );\r
540 \r
541   CHECK( IsWordInSession("RICE") );\r
542   CHECK(!IsWordInSession("RIce") );\r
543   CHECK( IsWordInSession("Rice") );\r
544   CHECK( IsWordInSession("rice") );\r
545   CHECK(!IsWordInSession("rIce") );\r
546 }\r
547 \r
548 TEST_FIXTURE(EnchantPwl_TestFixture, \r
549              IsWordInDictionary_AddedAllCapsOfTrueTitleCase_OnlyAllCapsSuccessful)\r
550 {\r
551   AddWordToDictionary(Convert(L"\x01f1IE")); // u01f1 is Latin captial letter Dz\r
552 \r
553   CHECK( IsWordInDictionary(Convert(L"\x01f1IE")) ); // u01f1 is Latin captial letter Dz\r
554   CHECK(!IsWordInDictionary(Convert(L"\x01f2IE")) ); // u01f2 is Latin capital letter d with small letter z\r
555   CHECK(!IsWordInDictionary(Convert(L"\x01f2ie")) ); // u01f2 is Latin capital letter d with small letter z\r
556   CHECK(!IsWordInDictionary(Convert(L"\x01f3ie")) ); // u01f3 is Latin small letter dz\r
557   CHECK(!IsWordInDictionary(Convert(L"\x01f3Ie")) );\r
558 \r
559   CHECK( IsWordInSession(Convert(L"\x01f1IE")) ); // u01f1 is Latin captial letter Dz\r
560   CHECK(!IsWordInSession(Convert(L"\x01f2IE")) ); // u01f2 is Latin capital letter d with small letter z\r
561   CHECK(!IsWordInSession(Convert(L"\x01f2ie")) ); // u01f2 is Latin capital letter d with small letter z\r
562   CHECK(!IsWordInSession(Convert(L"\x01f3ie")) ); // u01f3 is Latin small letter dz\r
563   CHECK(!IsWordInSession(Convert(L"\x01f3Ie")) );\r
564 }\r
565 \r
566 TEST_FIXTURE(EnchantPwl_TestFixture, \r
567              IsWordInDictionary_AddedTrueTitleCase_lowerCaseAndMixedCaseNotSuccessful)\r
568 {\r
569   AddWordToDictionary(Convert(L"\x01f2ie")); // u01f2 is Latin capital letter d with small letter z\r
570 \r
571   CHECK( IsWordInDictionary(Convert(L"\x01f1IE")) ); // u01f1 is Latin captial letter Dz\r
572   CHECK(!IsWordInDictionary(Convert(L"\x01f2IE")) ); // u01f2 is Latin capital letter d with small letter z\r
573   CHECK( IsWordInDictionary(Convert(L"\x01f2ie")) ); // u01f2 is Latin capital letter d with small letter z\r
574   CHECK(!IsWordInDictionary(Convert(L"\x01f3ie")) ); // u01f3 is Latin small letter dz\r
575   CHECK(!IsWordInDictionary(Convert(L"\x01f3Ie")) );\r
576 \r
577   CHECK( IsWordInSession(Convert(L"\x01f1IE")) ); // u01f1 is Latin captial letter Dz\r
578   CHECK(!IsWordInSession(Convert(L"\x01f2IE")) ); // u01f2 is Latin capital letter d with small letter z\r
579   CHECK( IsWordInSession(Convert(L"\x01f2ie")) ); // u01f2 is Latin capital letter d with small letter z\r
580   CHECK(!IsWordInSession(Convert(L"\x01f3ie")) ); // u01f3 is Latin small letter dz\r
581   CHECK(!IsWordInSession(Convert(L"\x01f3Ie")) );\r
582 }\r
583 \r
584 TEST_FIXTURE(EnchantPwl_TestFixture, \r
585              IsWordInDictionary_AddedLowerOfTrueTitleCase_MixedCaseNotSuccessful)\r
586 {\r
587   AddWordToDictionary(Convert(L"\x01f3ie")); // u01f2 is Latin small letter dz\r
588 \r
589   CHECK( IsWordInDictionary(Convert(L"\x01f1IE")) ); // u01f1 is Latin captial letter Dz\r
590   CHECK(!IsWordInDictionary(Convert(L"\x01f2IE")) ); // u01f2 is Latin capital letter d with small letter z\r
591   CHECK( IsWordInDictionary(Convert(L"\x01f2ie")) ); // u01f2 is Latin capital letter d with small letter z\r
592   CHECK( IsWordInDictionary(Convert(L"\x01f3ie")) ); // u01f3 is Latin small letter dz\r
593   CHECK(!IsWordInDictionary(Convert(L"\x01f3Ie")) );\r
594 \r
595   CHECK( IsWordInSession(Convert(L"\x01f1IE")) ); // u01f1 is Latin captial letter Dz\r
596   CHECK(!IsWordInSession(Convert(L"\x01f2IE")) ); // u01f2 is Latin capital letter d with small letter z\r
597   CHECK( IsWordInSession(Convert(L"\x01f2ie")) ); // u01f2 is Latin capital letter d with small letter z\r
598   CHECK( IsWordInSession(Convert(L"\x01f3ie")) ); // u01f3 is Latin small letter dz\r
599   CHECK(!IsWordInSession(Convert(L"\x01f3Ie")) );\r
600 }\r
601 \r
602 ///////////////////////////////////////////////////////////////////////////////////////////\r
603 // Capitalization on Suggestions\r
604 TEST_FIXTURE(EnchantPwl_TestFixture, \r
605              GetSuggestions_AddedAllCaps_WordAllCaps_SuggestionAllCaps)\r
606 {\r
607   AddWordToDictionary("CIA");\r
608 \r
609   std::vector<const std::string> suggestions = GetSuggestionsFromWord("CEA");\r
610 \r
611   std::vector<const std::string> expected;\r
612   expected.push_back("CIA");\r
613   CHECK_EQUAL(expected.size(), suggestions.size());\r
614   if(expected.size() == suggestions.size())\r
615   {\r
616       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
617   }\r
618 }\r
619 \r
620 TEST_FIXTURE(EnchantPwl_TestFixture, \r
621              GetSuggestions_AddedAllCaps_WordTitleCase_SuggestionAllCaps)\r
622 {\r
623   AddWordToDictionary("CIA");\r
624 \r
625   std::vector<const std::string> suggestions = GetSuggestionsFromWord("Cea");\r
626 \r
627   std::vector<const std::string> expected;\r
628   expected.push_back("CIA");\r
629   CHECK_EQUAL(expected.size(), suggestions.size());\r
630   if(expected.size() == suggestions.size())\r
631   {\r
632       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
633   }\r
634 }\r
635 \r
636 TEST_FIXTURE(EnchantPwl_TestFixture, \r
637              GetSuggestions_AddedAllCaps_WordLowerCase_SuggestionAllCaps)\r
638 {\r
639   AddWordToDictionary("CIA");\r
640 \r
641   std::vector<const std::string> suggestions = GetSuggestionsFromWord("cea");\r
642 \r
643   std::vector<const std::string> expected;\r
644   expected.push_back("CIA");\r
645   CHECK_EQUAL(expected.size(), suggestions.size());\r
646   if(expected.size() == suggestions.size())\r
647   {\r
648       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
649   }\r
650 }\r
651 \r
652 TEST_FIXTURE(EnchantPwl_TestFixture, \r
653              GetSuggestions_AddedTitleCase_WordAllCaps_SuggestionAllCaps)\r
654 {\r
655   AddWordToDictionary("Eric");\r
656 \r
657   std::vector<const std::string> suggestions = GetSuggestionsFromWord("RIC");\r
658 \r
659   std::vector<const std::string> expected;\r
660   expected.push_back("ERIC");\r
661   CHECK_EQUAL(expected.size(), suggestions.size());\r
662   CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
663 }\r
664 \r
665 TEST_FIXTURE(EnchantPwl_TestFixture, \r
666              GetSuggestions_AddedTitleCase_WordTitleCase_SuggestionTitleCase)\r
667 {\r
668   AddWordToDictionary("Eric");\r
669 \r
670   std::vector<const std::string> suggestions = GetSuggestionsFromWord("Ric");\r
671 \r
672   std::vector<const std::string> expected;\r
673   expected.push_back("Eric");\r
674   CHECK_EQUAL(expected.size(), suggestions.size());\r
675   CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
676 }\r
677 \r
678 TEST_FIXTURE(EnchantPwl_TestFixture, \r
679              GetSuggestions_AddedTitleCase_WordLowerCase_SuggestionTitleCase)\r
680 {\r
681   AddWordToDictionary("Eric");\r
682 \r
683   std::vector<const std::string> suggestions = GetSuggestionsFromWord("ric");\r
684 \r
685   std::vector<const std::string> expected;\r
686   expected.push_back("Eric");\r
687   CHECK_EQUAL(expected.size(), suggestions.size());\r
688   CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
689 }\r
690 \r
691 TEST_FIXTURE(EnchantPwl_TestFixture, \r
692              GetSuggestions_AddedLowerCase_WordAllCaps_SuggestionAllCaps)\r
693 {\r
694   AddWordToDictionary("rice");\r
695 \r
696   std::vector<const std::string> suggestions = GetSuggestionsFromWord("RIC");\r
697 \r
698   std::vector<const std::string> expected;\r
699   expected.push_back("RICE");\r
700   CHECK_EQUAL(expected.size(), suggestions.size());\r
701   CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
702 }\r
703 \r
704 TEST_FIXTURE(EnchantPwl_TestFixture, \r
705              GetSuggestions_AddedLowerCase_WordTitleCase_SuggestionTitleCase)\r
706 {\r
707   AddWordToDictionary("rice");\r
708 \r
709   std::vector<const std::string> suggestions = GetSuggestionsFromWord("Ric");\r
710 \r
711   std::vector<const std::string> expected;\r
712   expected.push_back("Rice");\r
713   CHECK_EQUAL(expected.size(), suggestions.size());\r
714   CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
715 }\r
716 \r
717 TEST_FIXTURE(EnchantPwl_TestFixture, \r
718              GetSuggestions_AddedLowerCase_WordLowerCase_SuggestionLowerCase)\r
719 {\r
720   AddWordToDictionary("rice");\r
721 \r
722   std::vector<const std::string> suggestions = GetSuggestionsFromWord("ric");\r
723 \r
724   std::vector<const std::string> expected;\r
725   expected.push_back("rice");\r
726   CHECK_EQUAL(expected.size(), suggestions.size());\r
727   CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
728 }\r
729 \r
730 \r
731 \r
732 \r
733 \r
734 \r
735 TEST_FIXTURE(EnchantPwl_TestFixture, \r
736              GetSuggestions_AddedAllCapsOfTrueTitleCase_WordAllCaps_SuggestionAllCaps)\r
737 {\r
738   AddWordToDictionary(Convert(L"\x01f1IE"));  // u01f1 is Latin captial letter Dz\r
739 \r
740   std::vector<const std::string> suggestions = GetSuggestionsFromWord("RIE");\r
741 \r
742   std::vector<const std::string> expected;\r
743   expected.push_back(Convert(L"\x01f1IE")); // u01f1 is Latin captial letter Dz\r
744   CHECK_EQUAL(expected.size(), suggestions.size());\r
745   if(expected.size() == suggestions.size())\r
746   {\r
747       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
748   }\r
749 }\r
750 \r
751 TEST_FIXTURE(EnchantPwl_TestFixture, \r
752              GetSuggestions_AddedAllCapsOfTrueTitleCase_WordTitleCase_SuggestionAllCaps)\r
753 {\r
754   AddWordToDictionary(Convert(L"\x01f1IE"));  // u01f1 is Latin captial letter Dz\r
755 \r
756   std::vector<const std::string> suggestions = GetSuggestionsFromWord("Rie");\r
757 \r
758   std::vector<const std::string> expected;\r
759   expected.push_back(Convert(L"\x01f1IE")); // u01f1 is Latin captial letter Dz\r
760   CHECK_EQUAL(expected.size(), suggestions.size());\r
761   if(expected.size() == suggestions.size())\r
762   {\r
763       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
764   }\r
765 }\r
766 \r
767 TEST_FIXTURE(EnchantPwl_TestFixture, \r
768              GetSuggestions_AddedAllCapsOfTrueTitleCase_WordLowerCase_SuggestionAllCaps)\r
769 {\r
770   AddWordToDictionary(Convert(L"\x01f1IE"));  // u01f1 is Latin captial letter Dz\r
771 \r
772   std::vector<const std::string> suggestions = GetSuggestionsFromWord("rie");\r
773 \r
774   std::vector<const std::string> expected;\r
775   expected.push_back(Convert(L"\x01f1IE")); // u01f1 is Latin captial letter Dz\r
776   CHECK_EQUAL(expected.size(), suggestions.size());\r
777   if(expected.size() == suggestions.size())\r
778   {\r
779       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
780   }\r
781 }\r
782 \r
783 TEST_FIXTURE(EnchantPwl_TestFixture, \r
784              GetSuggestions_AddedTitleCaseOfTrueTitleCase_WordAllCaps_SuggestionAllCaps)\r
785 {\r
786   AddWordToDictionary(Convert(L"\x01f2ie"));  // u01f2 is Latin capital letter d with small letter z\r
787 \r
788   std::vector<const std::string> suggestions = GetSuggestionsFromWord("RIE");\r
789 \r
790   std::vector<const std::string> expected;\r
791   expected.push_back(Convert(L"\x01f1IE")); // u01f1 is Latin captial letter Dz\r
792   CHECK_EQUAL(expected.size(), suggestions.size());\r
793   if(expected.size() == suggestions.size())\r
794   {\r
795       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
796   }\r
797 }\r
798 \r
799 TEST_FIXTURE(EnchantPwl_TestFixture, \r
800              GetSuggestions_AddedTitleCaseOfTrueTitleCase_WordTitleCase_SuggestionTitleCase)\r
801 {\r
802   AddWordToDictionary(Convert(L"\x01f2ie"));  // u01f2 is Latin capital letter d with small letter z\r
803 \r
804   std::vector<const std::string> suggestions = GetSuggestionsFromWord("Rie");\r
805 \r
806   std::vector<const std::string> expected;\r
807   expected.push_back(Convert(L"\x01f2ie")); // u01f2 is Latin capital letter d with small letter z\r
808   CHECK_EQUAL(expected.size(), suggestions.size());\r
809   if(expected.size() == suggestions.size())\r
810   {\r
811       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
812   }\r
813 }\r
814 \r
815 TEST_FIXTURE(EnchantPwl_TestFixture, \r
816              GetSuggestions_AddedTitleCaseOfTrueTitleCase_WordLowerCase_SuggestionTitleCase)\r
817 {\r
818   AddWordToDictionary(Convert(L"\x01f2ie"));  // u01f2 is Latin capital letter d with small letter z\r
819 \r
820   std::vector<const std::string> suggestions = GetSuggestionsFromWord("rie");\r
821 \r
822   std::vector<const std::string> expected;\r
823   expected.push_back(Convert(L"\x01f2ie")); // u01f2 is Latin capital letter d with small letter z\r
824   CHECK_EQUAL(expected.size(), suggestions.size());\r
825   if(expected.size() == suggestions.size())\r
826   {\r
827       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
828   }\r
829 }\r
830 \r
831 TEST_FIXTURE(EnchantPwl_TestFixture, \r
832              GetSuggestions_AddedLowerCaseOfTrueTitleCase_WordAllCaps_SuggestionAllCaps)\r
833 {\r
834   AddWordToDictionary(Convert(L"\x01f3ie"));  // u01f3 is Latin small letter dz\r
835 \r
836   std::vector<const std::string> suggestions = GetSuggestionsFromWord("RIE");\r
837 \r
838   std::vector<const std::string> expected;\r
839   expected.push_back(Convert(L"\x01f1IE")); // u01f1 is Latin captial letter Dz\r
840   CHECK_EQUAL(expected.size(), suggestions.size());\r
841   if(expected.size() == suggestions.size())\r
842   {\r
843       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
844   }\r
845 }\r
846 \r
847 TEST_FIXTURE(EnchantPwl_TestFixture, \r
848              GetSuggestions_AddedLowerCaseOfTrueTitleCase_WordTitleCase_SuggestionTitleCase)\r
849 {\r
850   AddWordToDictionary(Convert(L"\x01f3ie"));  // u01f3 is Latin small letter dz\r
851 \r
852   std::vector<const std::string> suggestions = GetSuggestionsFromWord("Rie");\r
853 \r
854   std::vector<const std::string> expected;\r
855   expected.push_back(Convert(L"\x01f2ie")); // u01f2 is Latin capital letter d with small letter z\r
856   CHECK_EQUAL(expected.size(), suggestions.size());\r
857   if(expected.size() == suggestions.size())\r
858   {\r
859       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
860   }\r
861 }\r
862 \r
863 TEST_FIXTURE(EnchantPwl_TestFixture, \r
864              GetSuggestions_AddedLowerCaseOfTrueTitleCase_WordLowerCase_SuggestionLowerCase)\r
865 {\r
866   AddWordToDictionary(Convert(L"\x01f3ie"));  // u01f3 is Latin small letter dz\r
867 \r
868   std::vector<const std::string> suggestions = GetSuggestionsFromWord("rie");\r
869 \r
870   std::vector<const std::string> expected;\r
871   expected.push_back(Convert(L"\x01f3ie")); // u01f3 is Latin small letter dz\r
872   CHECK_EQUAL(expected.size(), suggestions.size());\r
873   if(expected.size() == suggestions.size())\r
874   {\r
875       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
876   }\r
877 }\r
878 \r
879 \r
880 TEST_FIXTURE(EnchantPwl_TestFixture, \r
881              GetSuggestions_AddedAllCapsWithPrefix_WordLowerCase_SuggestionAllCaps)\r
882 {\r
883   AddWordToDictionary("CIAL");\r
884   AddWordToDictionary("CIALAND");\r
885 \r
886   std::vector<const std::string> suggestions = GetSuggestionsFromWord("ceal");\r
887 \r
888   std::vector<const std::string> expected;\r
889   expected.push_back("CIAL");\r
890   CHECK_EQUAL(expected.size(), suggestions.size());\r
891   if(expected.size() == suggestions.size())\r
892   {\r
893       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
894   }\r
895 }\r
896 \r
897 TEST_FIXTURE(EnchantPwl_TestFixture, \r
898              GetSuggestions_AddedTitleCaseWithPrefix_WordLowerCase_SuggestionTitlecase)\r
899 {\r
900   AddWordToDictionary("Eric");\r
901   AddWordToDictionary("Ericson");\r
902 \r
903   std::vector<const std::string> suggestions = GetSuggestionsFromWord("eruc");\r
904 \r
905   std::vector<const std::string> expected;\r
906   expected.push_back("Eric");\r
907   CHECK_EQUAL(expected.size(), suggestions.size());\r
908   if(expected.size() == suggestions.size())\r
909   {\r
910       CHECK_ARRAY_EQUAL(expected, suggestions, expected.size());\r
911   }\r
912 }\r
913 \r
914 /////////////////////////////////////////////////////////////////////////////\r
915 // Remove from PWL\r
916 TEST_FIXTURE(EnchantPwl_TestFixture, \r
917              PwlRemove_SharedPrefix1)\r
918 {\r
919   AddWordToDictionary("help");\r
920   AddWordToDictionary("hello");\r
921 \r
922   CHECK( IsWordInDictionary("help") );\r
923   CHECK( IsWordInDictionary("hello") );\r
924 \r
925   RemoveWordFromDictionary("help");\r
926 \r
927   CHECK(!IsWordInDictionary("help") );\r
928   CHECK( IsWordInDictionary("hello") );\r
929 }\r
930 \r
931 TEST_FIXTURE(EnchantPwl_TestFixture, \r
932              PwlRemove_SharedPrefix2)\r
933 {\r
934   AddWordToDictionary("help");\r
935   AddWordToDictionary("hello");\r
936 \r
937   CHECK( IsWordInDictionary("help") );\r
938   CHECK( IsWordInDictionary("hello") );\r
939 \r
940   RemoveWordFromDictionary("hello");\r
941 \r
942   CHECK( IsWordInDictionary("help") );\r
943   CHECK(!IsWordInDictionary("hello") );\r
944 }\r
945 \r
946 TEST_FIXTURE(EnchantPwl_TestFixture, \r
947              PwlRemove_SharedPrefix3)\r
948 {\r
949   AddWordToDictionary("help");\r
950   AddWordToDictionary("hello");\r
951   AddWordToDictionary("helm");\r
952 \r
953   CHECK( IsWordInDictionary("help") );\r
954   CHECK( IsWordInDictionary("hello") );\r
955   CHECK( IsWordInDictionary("helm") );\r
956 \r
957   RemoveWordFromDictionary("hello");\r
958 \r
959   CHECK( IsWordInDictionary("help") );\r
960   CHECK(!IsWordInDictionary("hello") );\r
961   CHECK( IsWordInDictionary("helm") );\r
962 }\r
963 \r
964 TEST_FIXTURE(EnchantPwl_TestFixture, \r
965              PwlRemove_SharedPrefix4)\r
966 {\r
967   AddWordToDictionary("help");\r
968   AddWordToDictionary("hello");\r
969   AddWordToDictionary("helm");\r
970 \r
971   CHECK( IsWordInDictionary("help") );\r
972   CHECK( IsWordInDictionary("hello") );\r
973   CHECK( IsWordInDictionary("helm") );\r
974 \r
975   RemoveWordFromDictionary("help");\r
976 \r
977   CHECK(!IsWordInDictionary("help") );\r
978   CHECK( IsWordInDictionary("hello") );\r
979   CHECK( IsWordInDictionary("helm") );\r
980 }\r
981 \r
982 TEST_FIXTURE(EnchantPwl_TestFixture, \r
983              PwlRemove_SingleWord)\r
984 {\r
985   AddWordToDictionary("hello");\r
986 \r
987   CHECK( IsWordInDictionary("hello") );\r
988 \r
989   RemoveWordFromDictionary("hello");\r
990 \r
991   CHECK(!IsWordInDictionary("hello") );\r
992 }\r
993 \r
994 TEST_FIXTURE(EnchantPwl_TestFixture, \r
995              PwlRemove_MultipleWords1)\r
996 {\r
997   AddWordToDictionary("special");\r
998   AddWordToDictionary("hello");\r
999 \r
1000   CHECK( IsWordInDictionary("special") );\r
1001   CHECK( IsWordInDictionary("hello") );\r
1002 \r
1003   RemoveWordFromDictionary("hello");\r
1004 \r
1005   CHECK( IsWordInDictionary("special") );\r
1006   CHECK(!IsWordInDictionary("hello") );\r
1007 }\r
1008 \r
1009 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1010              PwlRemove_MultipleWords2)\r
1011 {\r
1012   AddWordToDictionary("special");\r
1013   AddWordToDictionary("hello");\r
1014 \r
1015   CHECK( IsWordInDictionary("special") );\r
1016   CHECK( IsWordInDictionary("hello") );\r
1017 \r
1018   RemoveWordFromDictionary("special");\r
1019 \r
1020   CHECK(!IsWordInDictionary("special") );\r
1021   CHECK( IsWordInDictionary("hello") );\r
1022 }\r
1023 \r
1024 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1025              PwlRemove_ProperPrefix1)\r
1026 {\r
1027   AddWordToDictionary("ant");\r
1028   AddWordToDictionary("anteater");\r
1029 \r
1030   CHECK( IsWordInDictionary("ant") );\r
1031   CHECK( IsWordInDictionary("anteater") );\r
1032 \r
1033   RemoveWordFromDictionary("ant");\r
1034 \r
1035   CHECK(!IsWordInDictionary("ant") );\r
1036   CHECK( IsWordInDictionary("anteater") );\r
1037 }\r
1038 \r
1039 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1040              PwlRemove_ProperPrefix2)\r
1041 {\r
1042   AddWordToDictionary("anteater");\r
1043   AddWordToDictionary("ant");\r
1044 \r
1045   CHECK( IsWordInDictionary("ant") );\r
1046   CHECK( IsWordInDictionary("anteater") );\r
1047 \r
1048   RemoveWordFromDictionary("ant");\r
1049 \r
1050   CHECK(!IsWordInDictionary("ant") );\r
1051   CHECK( IsWordInDictionary("anteater") );\r
1052 }\r
1053 \r
1054 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1055              PwlRemove_ProperPrefix3)\r
1056 {\r
1057   AddWordToDictionary("ant");\r
1058   AddWordToDictionary("anteater");\r
1059 \r
1060   CHECK( IsWordInDictionary("ant") );\r
1061   CHECK( IsWordInDictionary("anteater") );\r
1062 \r
1063   RemoveWordFromDictionary("anteater");\r
1064 \r
1065   CHECK( IsWordInDictionary("ant") );\r
1066   CHECK(!IsWordInDictionary("anteater") );\r
1067 }\r
1068 \r
1069 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1070              PwlRemove_ProperPrefix4)\r
1071 {\r
1072   AddWordToDictionary("anteater");\r
1073   AddWordToDictionary("ant");\r
1074 \r
1075   CHECK( IsWordInDictionary("ant") );\r
1076   CHECK( IsWordInDictionary("anteater") );\r
1077 \r
1078   RemoveWordFromDictionary("anteater");\r
1079 \r
1080   CHECK( IsWordInDictionary("ant") );\r
1081   CHECK(!IsWordInDictionary("anteater") );\r
1082 }\r
1083 \r
1084 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1085              PwlRemove_ItemRemovedFromFile)\r
1086 {\r
1087   std::vector<const std::string> sWords;\r
1088   sWords.push_back("cat");\r
1089   sWords.push_back("hat");\r
1090   sWords.push_back("that");\r
1091   sWords.push_back("bat");\r
1092   sWords.push_back("tot");\r
1093 \r
1094   std::vector<const std::string>::const_iterator removed = sWords.insert(sWords.begin()+2, "hello");\r
1095   AddWordsToDictionary(sWords);\r
1096 \r
1097   RemoveWordFromDictionary("hello");\r
1098 \r
1099   ReloadTestDictionary(); // to see what actually persisted\r
1100 \r
1101   for(std::vector<const std::string>::const_iterator itWord = sWords.begin(); itWord != removed; ++itWord){\r
1102     CHECK( IsWordInDictionary(*itWord) );\r
1103   }\r
1104   CHECK(!IsWordInDictionary(*removed) );\r
1105 \r
1106   for(std::vector<const std::string>::const_iterator itWord = removed+1; itWord != sWords.end(); ++itWord){\r
1107     CHECK(IsWordInDictionary(*itWord) );\r
1108   }\r
1109 }\r
1110 \r
1111 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1112              PwlRemove_ItemRemovedFromBeginningOfFile)\r
1113 {\r
1114   std::vector<const std::string> sWords;\r
1115   sWords.push_back("cat");\r
1116   sWords.push_back("hat");\r
1117   sWords.push_back("that");\r
1118   sWords.push_back("bat");\r
1119   sWords.push_back("tot");\r
1120 \r
1121   std::vector<const std::string>::const_iterator removed = sWords.insert(sWords.begin(), "hello");\r
1122   AddWordsToDictionary(sWords);\r
1123 \r
1124   RemoveWordFromDictionary("hello");\r
1125 \r
1126   ReloadTestDictionary(); // to see what actually persisted\r
1127 \r
1128   CHECK(!IsWordInDictionary(*removed) );\r
1129 \r
1130   for(std::vector<const std::string>::const_iterator itWord = removed+1; itWord != sWords.end(); ++itWord){\r
1131     CHECK(IsWordInDictionary(*itWord) );\r
1132   }\r
1133 }\r
1134 \r
1135 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1136              PwlRemove_ItemRemovedFromBeginningOfFileWithBOM)\r
1137 {\r
1138   char* Utf8Bom = "\xef\xbb\xbf";\r
1139 \r
1140   std::vector<const std::string> sWords;\r
1141   sWords.push_back("hello");\r
1142   sWords.push_back("cat");\r
1143   sWords.push_back("hat");\r
1144 \r
1145   Sleep(1000); // FAT systems have a 2 second resolution\r
1146                // NTFS is appreciably faster but no specs on what it is exactly\r
1147                // c runtime library's time_t has a 1 second resolution\r
1148   FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "at");\r
1149   if(f)\r
1150         {\r
1151                 fputs(Utf8Bom, f);\r
1152                 for(std::vector<const std::string>::const_iterator \r
1153                         itWord = sWords.begin();\r
1154             itWord != sWords.end();\r
1155             ++itWord)\r
1156         {\r
1157             if(itWord != sWords.begin()){\r
1158                             fputc('\n', f);\r
1159             }\r
1160                         fputs(itWord->c_str(), f);\r
1161                 }\r
1162                 fclose(f);\r
1163         }\r
1164 \r
1165   RemoveWordFromDictionary("hello");\r
1166 \r
1167   ReloadTestDictionary(); // to see what actually persisted\r
1168 \r
1169   CHECK(!IsWordInDictionary("hello") );\r
1170 \r
1171   for(std::vector<const std::string>::const_iterator itWord = sWords.begin()+1; itWord != sWords.end(); ++itWord){\r
1172     CHECK(IsWordInDictionary(*itWord) );\r
1173   }\r
1174 }\r
1175 \r
1176 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1177              PwlRemove_ItemRemovedFromEndOfFile)\r
1178 {\r
1179   std::vector<const std::string> sWords;\r
1180   sWords.push_back("cat");\r
1181   sWords.push_back("hat");\r
1182   sWords.push_back("that");\r
1183   sWords.push_back("bat");\r
1184   sWords.push_back("tot");\r
1185 \r
1186   std::vector<const std::string>::const_iterator removed = sWords.insert(sWords.end(), "hello");\r
1187   AddWordsToDictionary(sWords);\r
1188 \r
1189   RemoveWordFromDictionary("hello");\r
1190 \r
1191   ReloadTestDictionary(); // to see what actually persisted\r
1192 \r
1193   for(std::vector<const std::string>::const_iterator itWord = sWords.begin(); itWord != removed; ++itWord){\r
1194     CHECK( IsWordInDictionary(*itWord) );\r
1195   }\r
1196   CHECK(!IsWordInDictionary(*removed) );\r
1197 }\r
1198 \r
1199 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1200              PwlRemove_ItemRemovedFromEndOfFile_ExternalSetup)\r
1201 {\r
1202   std::vector<const std::string> sWords;\r
1203   sWords.push_back("cat");\r
1204   sWords.push_back("hat");\r
1205   sWords.push_back("that");\r
1206   sWords.push_back("bat");\r
1207   sWords.push_back("tot");\r
1208 \r
1209   std::vector<const std::string>::const_iterator removed = sWords.insert(sWords.end(), "hello");\r
1210   ExternalAddWordsToDictionary(sWords);\r
1211 \r
1212   RemoveWordFromDictionary("hello");\r
1213 \r
1214   ReloadTestDictionary(); // to see what actually persisted\r
1215 \r
1216   for(std::vector<const std::string>::const_iterator itWord = sWords.begin(); itWord != removed; ++itWord){\r
1217     CHECK( IsWordInDictionary(*itWord) );\r
1218   }\r
1219   CHECK(!IsWordInDictionary(*removed) );\r
1220 }\r
1221 \r
1222 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1223              PwlRemove_FileHasProperSubset_ItemRemovedFromFile)\r
1224 {\r
1225   std::vector<const std::string> sWords;\r
1226   sWords.push_back("cat");\r
1227   sWords.push_back("hat");\r
1228   sWords.push_back("that");\r
1229   sWords.push_back("bat");\r
1230   sWords.push_back("tot");\r
1231   sWords.push_back("anteater");\r
1232 \r
1233   std::vector<const std::string>::const_iterator removed = sWords.insert(sWords.end(), "ant");\r
1234   AddWordsToDictionary(sWords);\r
1235   RemoveWordFromDictionary("ant");\r
1236 \r
1237   ReloadTestDictionary(); // to see what actually persisted\r
1238 \r
1239   for(std::vector<const std::string>::const_iterator itWord = sWords.begin(); itWord != removed; ++itWord){\r
1240     CHECK( IsWordInDictionary(*itWord) );\r
1241   }\r
1242   CHECK(!IsWordInDictionary(*removed) );\r
1243 }\r
1244 \r
1245 //////////////////////////////////////////////////////////////////////////////////////////////////////////\r
1246 // Pwl Edit distance\r
1247 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1248              PwlSuggest_HasProperSubset_SubstituteFirstChar)\r
1249 {\r
1250   std::vector<const std::string> sWords;\r
1251   sWords.push_back("cat");  //1\r
1252 \r
1253   AddWordsToDictionary(sWords);\r
1254 \r
1255   AddWordToDictionary("catsup"); //4\r
1256 \r
1257   std::vector<const std::string> suggestions = GetSuggestionsFromWord("tat");\r
1258 \r
1259   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1260 \r
1261   std::sort(sWords.begin(), sWords.end());\r
1262   std::sort(suggestions.begin(), suggestions.end());\r
1263 \r
1264   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1265 }\r
1266 \r
1267 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1268              PwlSuggest_HasProperSubset_SubstituteFirstChar_Insert1)\r
1269 {\r
1270   std::vector<const std::string> sWords;\r
1271   sWords.push_back("cats"); //2\r
1272 \r
1273   AddWordsToDictionary(sWords);\r
1274 \r
1275   AddWordToDictionary("catsup"); //4\r
1276 \r
1277   std::vector<const std::string> suggestions = GetSuggestionsFromWord("tat");\r
1278 \r
1279   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1280 \r
1281   std::sort(sWords.begin(), sWords.end());\r
1282   std::sort(suggestions.begin(), suggestions.end());\r
1283 \r
1284   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1285 }\r
1286 \r
1287 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1288              PwlSuggest_HasProperSubset_SubstituteFirstChar_Insert2)\r
1289 {\r
1290   std::vector<const std::string> sWords;\r
1291   sWords.push_back("catch"); //3\r
1292 \r
1293   AddWordsToDictionary(sWords);\r
1294 \r
1295   AddWordToDictionary("catchy"); //4\r
1296 \r
1297   std::vector<const std::string> suggestions = GetSuggestionsFromWord("tat");\r
1298 \r
1299   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1300 \r
1301   std::sort(sWords.begin(), sWords.end());\r
1302   std::sort(suggestions.begin(), suggestions.end());\r
1303 \r
1304   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1305 }\r
1306 \r
1307 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1308              PwlSuggest_HasProperSubset_Insert1)\r
1309 {\r
1310   std::vector<const std::string> sWords;\r
1311   sWords.push_back("tad");  //1\r
1312 \r
1313   AddWordsToDictionary(sWords);\r
1314 \r
1315   AddWordToDictionary("taddle"); //4\r
1316 \r
1317   std::vector<const std::string> suggestions = GetSuggestionsFromWord("ta");\r
1318 \r
1319   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1320 \r
1321   std::sort(sWords.begin(), sWords.end());\r
1322   std::sort(suggestions.begin(), suggestions.end());\r
1323 \r
1324   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1325 }\r
1326 \r
1327 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1328              PwlSuggest_HasProperSubset_Insert2)\r
1329 {\r
1330   std::vector<const std::string> sWords;\r
1331   sWords.push_back("tote"); //2\r
1332 \r
1333   AddWordsToDictionary(sWords);\r
1334 \r
1335   AddWordToDictionary("totems"); //4\r
1336 \r
1337   std::vector<const std::string> suggestions = GetSuggestionsFromWord("to");\r
1338 \r
1339   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1340 \r
1341   std::sort(sWords.begin(), sWords.end());\r
1342   std::sort(suggestions.begin(), suggestions.end());\r
1343 \r
1344   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1345 }\r
1346 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1347              PwlSuggest_HasProperSubset_Insert3)\r
1348 {\r
1349   std::vector<const std::string> sWords;\r
1350   sWords.push_back("catch"); //3\r
1351 \r
1352   AddWordsToDictionary(sWords);\r
1353 \r
1354   AddWordToDictionary("catchy"); //4\r
1355 \r
1356   std::vector<const std::string> suggestions = GetSuggestionsFromWord("ca");\r
1357 \r
1358   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1359 \r
1360   std::sort(sWords.begin(), sWords.end());\r
1361   std::sort(suggestions.begin(), suggestions.end());\r
1362 \r
1363   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1364 }\r
1365 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1366              PwlSuggest_HasProperSubset_Delete1)\r
1367 {\r
1368   std::vector<const std::string> sWords;\r
1369   sWords.push_back("tape");  //1\r
1370 \r
1371   AddWordsToDictionary(sWords);\r
1372 \r
1373   AddWordToDictionary("tapestry"); //4\r
1374 \r
1375   std::vector<const std::string> suggestions = GetSuggestionsFromWord("tapen");\r
1376 \r
1377   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1378 \r
1379   std::sort(sWords.begin(), sWords.end());\r
1380   std::sort(suggestions.begin(), suggestions.end());\r
1381 \r
1382   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1383 }\r
1384 \r
1385 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1386              PwlSuggest_HasProperSubset_Delete2)\r
1387 {\r
1388   std::vector<const std::string> sWords;\r
1389   sWords.push_back("tot"); //2\r
1390 \r
1391   AddWordsToDictionary(sWords);\r
1392 \r
1393   AddWordToDictionary("totality"); //4\r
1394 \r
1395   std::vector<const std::string> suggestions = GetSuggestionsFromWord("totil");\r
1396 \r
1397   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1398 \r
1399   std::sort(sWords.begin(), sWords.end());\r
1400   std::sort(suggestions.begin(), suggestions.end());\r
1401 \r
1402   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1403 }\r
1404 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1405              PwlSuggest_HasProperSubset_Delete3)\r
1406 {\r
1407   std::vector<const std::string> sWords;\r
1408   sWords.push_back("cat"); //3\r
1409 \r
1410   AddWordsToDictionary(sWords);\r
1411 \r
1412   AddWordToDictionary("catcher"); //4\r
1413 \r
1414   std::vector<const std::string> suggestions = GetSuggestionsFromWord("catsip");\r
1415 \r
1416   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1417 \r
1418   std::sort(sWords.begin(), sWords.end());\r
1419   std::sort(suggestions.begin(), suggestions.end());\r
1420 \r
1421   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1422 }\r
1423 \r
1424 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1425              PwlSuggest_HasProperSubset_Substitute1)\r
1426 {\r
1427   std::vector<const std::string> sWords;\r
1428   sWords.push_back("small");  //1\r
1429 \r
1430   AddWordsToDictionary(sWords);\r
1431 \r
1432   AddWordToDictionary("smallest"); //4\r
1433 \r
1434   std::vector<const std::string> suggestions = GetSuggestionsFromWord("skall");\r
1435 \r
1436   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1437 \r
1438   std::sort(sWords.begin(), sWords.end());\r
1439   std::sort(suggestions.begin(), suggestions.end());\r
1440 \r
1441   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1442 }\r
1443 \r
1444 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1445              PwlSuggest_HasProperSubset_Substitute2)\r
1446 {\r
1447   std::vector<const std::string> sWords;\r
1448   sWords.push_back("catch"); //2\r
1449 \r
1450   AddWordsToDictionary(sWords);\r
1451 \r
1452   AddWordToDictionary("catcher"); //4\r
1453 \r
1454   std::vector<const std::string> suggestions = GetSuggestionsFromWord("cafdh");\r
1455 \r
1456   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1457 \r
1458   std::sort(sWords.begin(), sWords.end());\r
1459   std::sort(suggestions.begin(), suggestions.end());\r
1460 \r
1461   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1462 }\r
1463 \r
1464 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1465              PwlSuggest_HasProperSubset_Substitute3)\r
1466 {\r
1467   std::vector<const std::string> sWords;\r
1468   sWords.push_back("hasten"); //3\r
1469 \r
1470   AddWordsToDictionary(sWords);\r
1471 \r
1472   AddWordToDictionary("hastens"); //4\r
1473 \r
1474   std::vector<const std::string> suggestions = GetSuggestionsFromWord("hasopo");\r
1475 \r
1476   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1477 \r
1478   std::sort(sWords.begin(), sWords.end());\r
1479   std::sort(suggestions.begin(), suggestions.end());\r
1480 \r
1481   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1482 }\r
1483 \r
1484 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1485              PwlSuggest_HasProperSubset_Transpose1)\r
1486 {\r
1487   std::vector<const std::string> sWords;\r
1488   sWords.push_back("small");  //1\r
1489 \r
1490   AddWordsToDictionary(sWords);\r
1491 \r
1492   AddWordToDictionary("smallest"); //4\r
1493 \r
1494   std::vector<const std::string> suggestions = GetSuggestionsFromWord("smlal");\r
1495 \r
1496   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1497 \r
1498   std::sort(sWords.begin(), sWords.end());\r
1499   std::sort(suggestions.begin(), suggestions.end());\r
1500 \r
1501   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1502 }\r
1503 \r
1504 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1505              PwlSuggest_HasProperSubset_Transpose2)\r
1506 {\r
1507   std::vector<const std::string> sWords;\r
1508   sWords.push_back("catch"); //2\r
1509 \r
1510   AddWordsToDictionary(sWords);\r
1511 \r
1512   AddWordToDictionary("catcher"); //4\r
1513 \r
1514   std::vector<const std::string> suggestions = GetSuggestionsFromWord("acthc");\r
1515 \r
1516   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1517 \r
1518   std::sort(sWords.begin(), sWords.end());\r
1519   std::sort(suggestions.begin(), suggestions.end());\r
1520 \r
1521   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1522 }\r
1523 \r
1524 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1525              PwlSuggest_HasProperSubset_Transpose3)\r
1526 {\r
1527   std::vector<const std::string> sWords;\r
1528   sWords.push_back("hasten"); //3\r
1529 \r
1530   AddWordsToDictionary(sWords);\r
1531 \r
1532   AddWordToDictionary("hastens"); //4\r
1533 \r
1534   std::vector<const std::string> suggestions = GetSuggestionsFromWord("ahtsne");\r
1535 \r
1536   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1537 \r
1538   std::sort(sWords.begin(), sWords.end());\r
1539   std::sort(suggestions.begin(), suggestions.end());\r
1540 \r
1541   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1542 }\r
1543 \r
1544 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1545              PwlSuggest_Transpose1Insert2)\r
1546 {\r
1547   std::vector<const std::string> sWords;\r
1548   sWords.push_back("catch"); //3\r
1549 \r
1550   AddWordsToDictionary(sWords);\r
1551 \r
1552   std::vector<const std::string> suggestions = GetSuggestionsFromWord("act");\r
1553 \r
1554   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1555 \r
1556   std::sort(sWords.begin(), sWords.end());\r
1557   std::sort(suggestions.begin(), suggestions.end());\r
1558 \r
1559   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1560 }\r
1561 \r
1562 TEST_FIXTURE(EnchantPwl_TestFixture, \r
1563              PwlSuggest_Transpose2)\r
1564 {\r
1565   std::vector<const std::string> sWords;\r
1566   sWords.push_back("catch"); //2\r
1567 \r
1568   AddWordsToDictionary(sWords);\r
1569 \r
1570   std::vector<const std::string> suggestions = GetSuggestionsFromWord("acthc");\r
1571 \r
1572   CHECK_EQUAL(sWords.size(), suggestions.size());\r
1573 \r
1574   std::sort(sWords.begin(), sWords.end());\r
1575   std::sort(suggestions.begin(), suggestions.end());\r
1576 \r
1577   CHECK_ARRAY_EQUAL(sWords, suggestions, std::min(sWords.size(), suggestions.size()));\r
1578 }\r
1579 \r