summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Albright <eric_albright@sil.org>2007-11-17 09:36:14 +0000
committerEric Albright <eric_albright@sil.org>2007-11-17 09:36:14 +0000
commit4f82ec73d25c09af4ac3f364d549e49c40ec9a8e (patch)
tree225db207995cf507e42b4c9b516009558b35f43b
parent9175880905758e48e5c334b16817753698290ac7 (diff)
downloadenchant-4f82ec73d25c09af4ac3f364d549e49c40ec9a8e.tar.gz
Utf-8 validation
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@22313 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r--src/enchant.c107
-rw-r--r--unittests/broker/enchant_broker_describe_tests.cpp60
-rw-r--r--unittests/broker/enchant_broker_request_pwl_dict_tests.cpp11
-rw-r--r--unittests/dictionary/enchant_dict_add_to_pwl_tests.cpp6
-rw-r--r--unittests/dictionary/enchant_dict_add_to_session_tests.cpp7
-rw-r--r--unittests/dictionary/enchant_dict_check_tests.cpp7
-rw-r--r--unittests/dictionary/enchant_dict_is_in_session_tests.cpp8
-rw-r--r--unittests/dictionary/enchant_dict_store_replacement_tests.cpp14
-rw-r--r--unittests/dictionary/enchant_dict_suggest_tests.cpp56
-rw-r--r--unittests/provider/enchant_provider_broker_set_error_tests.cpp8
-rw-r--r--unittests/provider/enchant_provider_dict_set_error_tests.cpp7
11 files changed, 254 insertions, 37 deletions
diff --git a/src/enchant.c b/src/enchant.c
index c919c45..a6882f1 100644
--- a/src/enchant.c
+++ b/src/enchant.c
@@ -484,7 +484,8 @@ enchant_dict_set_error (EnchantDict * dict, const char * const err)
g_return_if_fail (dict);
g_return_if_fail (err);
-
+ g_return_if_fail (g_utf8_validate(err, -1, NULL));
+
session = (EnchantSession*)dict->enchant_private_data;
enchant_session_clear_error (session);
@@ -495,7 +496,7 @@ enchant_dict_set_error (EnchantDict * dict, const char * const err)
* enchant_dict_get_error
* @dict: A non-null dictionary
*
- * Returns a const char string or NULL describing the last exception.
+ * Returns a const char string or NULL describing the last exception in UTF8 encoding.
* WARNING: error is transient. It will likely be cleared as soon as
* the next dictionary operation is called
*
@@ -536,6 +537,7 @@ enchant_dict_check (EnchantDict * dict, const char *const word, ssize_t len)
len = strlen (word);
g_return_val_if_fail (len, -1);
+ g_return_val_if_fail (g_utf8_validate(word, len, NULL),-1);
session = (EnchantSession*)dict->enchant_private_data;
enchant_session_clear_error (session);
@@ -552,6 +554,52 @@ enchant_dict_check (EnchantDict * dict, const char *const word, ssize_t len)
return -1;
}
+/*@suggs must have at least n_suggs + n_new_suggs space allocated
+@n_suggs is the number if items currently appearing in @suggs
+
+returns the number of items in @suggs after merge is complete
+*/
+static int
+enchant_dict_merge_suggestions(EnchantDict * dict,
+ const char ** suggs,
+ size_t n_suggs,
+ const char * const* const new_suggs,
+ size_t n_new_suggs)
+{
+ EnchantSession * session;
+ size_t i, j;
+
+ session = (EnchantSession*)dict->enchant_private_data;
+
+ for(i = 0; i < n_new_suggs; i++)
+ {
+ int copy = 1;
+ size_t sugg_len = strlen(new_suggs[i]);
+
+ if (!g_utf8_validate(new_suggs[i], sugg_len, NULL))
+ copy = 0;
+ else
+ {
+ for(j = 0; j < n_suggs; j++)
+ {
+ if(strcmp(suggs[j],new_suggs[i])==0)
+ {
+ copy = 0; /*duplicate*/
+ break;
+ }
+ }
+ }
+
+ if(copy)
+ {
+ suggs[n_suggs] = g_strdup (new_suggs[i]);
+ ++n_suggs;
+ }
+ }
+
+ return n_suggs;
+}
+
/**
* enchant_dict_suggest
* @dict: A non-null #EnchantDict
@@ -579,6 +627,7 @@ enchant_dict_suggest (EnchantDict * dict, const char *const word,
len = strlen (word);
g_return_val_if_fail (len, NULL);
+ g_return_val_if_fail (g_utf8_validate(word, len, NULL), NULL);
session = (EnchantSession*)dict->enchant_private_data;
enchant_session_clear_error (session);
@@ -597,29 +646,17 @@ enchant_dict_suggest (EnchantDict * dict, const char *const word,
n_suggs = n_pwl_suggs + n_dict_suggs;
if (n_suggs > 0)
{
- size_t i, j, k;
-
suggs = g_new0 (char *, n_suggs + 1);
- /* Copy over suggestions from dict */
- for(i = 0; i < n_dict_suggs; i++)
- suggs[i] = g_strdup (dict_suggs[i]);
-
- /* Copy over suggestions from pwl, except dupes */
- for(j = 0; j < n_pwl_suggs; j++) {
- int dupe = 0;
- for(k = 0; k < n_dict_suggs; k++) {
- if(strcmp(suggs[k],pwl_suggs[j])==0) {
- dupe = 1;
- --n_suggs;
- break;
- }
- }
- if(!dupe) {
- suggs[i] = g_strdup (pwl_suggs[j]);
- i++;
- }
- }
+ /* Copy over suggestions from dict, if good */
+ n_suggs = enchant_dict_merge_suggestions(dict,
+ suggs, 0,
+ dict_suggs, n_dict_suggs);
+
+ /* Copy over suggestions from pwl, if good and no dupes */
+ n_suggs = enchant_dict_merge_suggestions(dict,
+ suggs, n_suggs,
+ pwl_suggs, n_pwl_suggs);
}
else
{
@@ -658,6 +695,8 @@ enchant_dict_add_to_pwl (EnchantDict * dict, const char *const word,
len = strlen (word);
g_return_if_fail (len);
+ g_return_if_fail (g_utf8_validate(word, len, NULL));
+
session = (EnchantSession*)dict->enchant_private_data;
enchant_session_clear_error (session);
enchant_session_add_personal (session, word, len);
@@ -701,7 +740,8 @@ enchant_dict_add_to_session (EnchantDict * dict, const char *const word,
len = strlen (word);
g_return_if_fail (len);
-
+ g_return_if_fail (g_utf8_validate(word, len, NULL));
+
session = (EnchantSession*)dict->enchant_private_data;
enchant_session_clear_error (session);
@@ -713,7 +753,7 @@ enchant_dict_add_to_session (EnchantDict * dict, const char *const word,
/**
* enchant_dict_is_in_session
* @dict: A non-null #EnchantDict
- * @word: The word you wish to see if it's in your session
+ * @word: The word you wish to see if it's in your session in UTF8 encoding
* @len: the byte length of @word, or -1 for strlen (@word)
*/
ENCHANT_MODULE_EXPORT (int)
@@ -729,6 +769,7 @@ enchant_dict_is_in_session (EnchantDict * dict, const char *const word,
len = strlen (word);
g_return_val_if_fail (len, 0);
+ g_return_val_if_fail (g_utf8_validate(word, len, NULL), 0);
session = (EnchantSession*)dict->enchant_private_data;
enchant_session_clear_error (session);
@@ -768,6 +809,9 @@ enchant_dict_store_replacement (EnchantDict * dict,
g_return_if_fail (mis_len);
g_return_if_fail (cor_len);
+ g_return_if_fail (g_utf8_validate(mis, mis_len, NULL));
+ g_return_if_fail (g_utf8_validate(cor, cor_len, NULL));
+
session = (EnchantSession*)dict->enchant_private_data;
enchant_session_clear_error (session);
@@ -881,12 +925,22 @@ enchant_provider_is_valid(EnchantProvider * provider)
g_warning ("EnchantProvider's identify method cannot be NULL\n");
return 0;
}
+ else if(!g_utf8_validate((*provider->identify)(provider), -1, NULL))
+ {
+ g_warning ("EnchantProvider's identify method does not return valid utf8.\n");
+ return 0;
+ }
if(provider->describe == NULL)
{
g_warning ("EnchantProvider's describe method cannot be NULL\n");
return 0;
}
+ else if(!g_utf8_validate((*provider->describe)(provider), -1, NULL))
+ {
+ g_warning ("EnchantProvider's describe method does not return valid utf8.\n");
+ return 0;
+ }
return 1;
}
@@ -1638,6 +1692,7 @@ enchant_provider_set_error (EnchantProvider * provider, const char * const err)
g_return_if_fail (provider);
g_return_if_fail (err);
+ g_return_if_fail (g_utf8_validate(err, -1, NULL));
broker = provider->owner;
g_return_if_fail (broker);
@@ -1650,7 +1705,7 @@ enchant_provider_set_error (EnchantProvider * provider, const char * const err)
* enchant_broker_get_error
* @broker: A non-null broker
*
- * Returns a const char string or NULL describing the last exception.
+ * Returns a const char string or NULL describing the last exception in UTF8 encoding.
* WARNING: error is transient and is likely cleared as soon as the
* next broker operation happens
*/
diff --git a/unittests/broker/enchant_broker_describe_tests.cpp b/unittests/broker/enchant_broker_describe_tests.cpp
index 677e6ec..c6958b0 100644
--- a/unittests/broker/enchant_broker_describe_tests.cpp
+++ b/unittests/broker/enchant_broker_describe_tests.cpp
@@ -157,6 +157,42 @@ struct EnchantBrokerDescribe_ProviderLacksDescribe_TestFixture : EnchantBrokerDe
}
};
+static char *
+MockProviderIllegalUtf8 (EnchantProvider *)
+{
+ return "\xa5\xf1\x08";
+}
+
+static void List_Providers_ProviderConfigurationInvalidIdentify (EnchantProvider * me, const char *)
+{
+ me->identify = MockProviderIllegalUtf8;
+}
+
+struct EnchantBrokerDescribe_ProviderHasInvalidUtf8Identify_TestFixture : EnchantBrokerDescribeTestFixtureBase
+{
+ //Setup
+ EnchantBrokerDescribe_ProviderHasInvalidUtf8Identify_TestFixture():
+ EnchantBrokerDescribeTestFixtureBase(List_Providers_ProviderConfigurationInvalidIdentify)
+ {
+ global_user_data = NULL;
+ }
+};
+
+static void List_Providers_ProviderConfigurationInvalidDescribe (EnchantProvider * me, const char *)
+{
+ me->describe = MockProviderIllegalUtf8;
+}
+
+struct EnchantBrokerDescribe_ProviderHasInvalidUtf8Describe_TestFixture : EnchantBrokerDescribeTestFixtureBase
+{
+ //Setup
+ EnchantBrokerDescribe_ProviderHasInvalidUtf8Describe_TestFixture():
+ EnchantBrokerDescribeTestFixtureBase(List_Providers_ProviderConfigurationInvalidDescribe)
+ {
+ global_user_data = NULL;
+ }
+};
+
/**
* enchant_broker_describe
* @broker: A non-null #EnchantBroker
@@ -170,7 +206,7 @@ struct EnchantBrokerDescribe_ProviderLacksDescribe_TestFixture : EnchantBrokerDe
/*
* Providers are discovered by probing first in the .enchant directory
- * in the user's home directory.
+ * in the user's home directory.
*
* The user's home directory on windows can be overridden using the registry
* setting HKEY_CURRENT_USER\Software\Enchant\Config\Home_Dir
@@ -271,4 +307,24 @@ TEST_FIXTURE(EnchantBrokerDescribe_ProviderLacksDescribe_TestFixture,
CHECK_EQUAL(1, std::count_if(_providerList.begin(),
_providerList.end(),
std::mem_fun_ref(&ProviderDescription::DataIsComplete)));
-} \ No newline at end of file
+}
+
+TEST_FIXTURE(EnchantBrokerDescribe_ProviderHasInvalidUtf8Describe_TestFixture,
+ EnchantBrokerDescribe_ProviderHasInvalidUtf8Describe_NotLoaded)
+{
+ enchant_broker_describe(_broker, EnchantBrokerDescribeCallback, &_providerList);
+ CHECK_EQUAL((unsigned int)1, _providerList.size());
+ CHECK_EQUAL(1, std::count_if(_providerList.begin(),
+ _providerList.end(),
+ std::mem_fun_ref(&ProviderDescription::DataIsComplete)));
+}
+
+TEST_FIXTURE(EnchantBrokerDescribe_ProviderHasInvalidUtf8Identify_TestFixture,
+ EnchantBrokerDescribe_ProviderHasInvalidUtf8Identify_NotLoaded)
+{
+ enchant_broker_describe(_broker, EnchantBrokerDescribeCallback, &_providerList);
+ CHECK_EQUAL((unsigned int)1, _providerList.size());
+ CHECK_EQUAL(1, std::count_if(_providerList.begin(),
+ _providerList.end(),
+ std::mem_fun_ref(&ProviderDescription::DataIsComplete)));
+}
diff --git a/unittests/broker/enchant_broker_request_pwl_dict_tests.cpp b/unittests/broker/enchant_broker_request_pwl_dict_tests.cpp
index 23cebfb..a4f11c5 100644
--- a/unittests/broker/enchant_broker_request_pwl_dict_tests.cpp
+++ b/unittests/broker/enchant_broker_request_pwl_dict_tests.cpp
@@ -126,4 +126,13 @@ TEST_FIXTURE(EnchantBrokerRequestPwlDictionary_TestFixture,
CHECK(!_dict);
CHECK((void*)enchant_broker_get_error(_broker));
#endif
-} \ No newline at end of file
+}
+
+#if defined(_WIN32)
+TEST_FIXTURE(EnchantBrokerRequestPwlDictionary_TestFixture,
+ EnchantBrokerRequestPwlDictionary_IllegalUtf8InFilename_NULL)
+{
+ _dict = enchant_broker_request_pwl_dict(_broker, "abc\xa5\xf1\x08");
+ CHECK(!_dict);
+}
+#endif
diff --git a/unittests/dictionary/enchant_dict_add_to_pwl_tests.cpp b/unittests/dictionary/enchant_dict_add_to_pwl_tests.cpp
index c4397aa..816c3d4 100644
--- a/unittests/dictionary/enchant_dict_add_to_pwl_tests.cpp
+++ b/unittests/dictionary/enchant_dict_add_to_pwl_tests.cpp
@@ -185,6 +185,12 @@ TEST_FIXTURE(EnchantDictionaryAddToPersonal_TestFixture,
CHECK(!addToPersonalCalled);
}
+TEST_FIXTURE(EnchantDictionaryAddToPersonal_TestFixture,
+ EnchantDictionaryAddToPersonal_InvalidUtf8Word_NotAdded)
+{
+ enchant_dict_add_to_pwl(_dict, "\xa5\xf1\x08", -1);
+ CHECK(!addToPersonalCalled);
+}
TEST_FIXTURE(EnchantDictionaryAddToPersonalNotImplemented_TestFixture,
EnchantDictionaryAddToPersonalNotImplemented_WordAddedToEnchantPwlFile)
diff --git a/unittests/dictionary/enchant_dict_add_to_session_tests.cpp b/unittests/dictionary/enchant_dict_add_to_session_tests.cpp
index bc86535..e3c2b29 100644
--- a/unittests/dictionary/enchant_dict_add_to_session_tests.cpp
+++ b/unittests/dictionary/enchant_dict_add_to_session_tests.cpp
@@ -188,6 +188,13 @@ TEST_FIXTURE(EnchantDictionaryAddToSession_TestFixture,
CHECK(!addToSessionCalled);
}
+TEST_FIXTURE(EnchantDictionaryAddToSession_TestFixture,
+ EnchantDictionaryAddToSession_InvalidUtf8Word_NotAdded)
+{
+ enchant_dict_add_to_session(_dict, "\xa5\xf1\x08", -1);
+ CHECK(!addToSessionCalled);
+}
+
TEST_FIXTURE(EnchantDictionaryAddToSessionNotImplemented_TestFixture,
EnchantDictionaryAddToSessionNotImplemented_WordAddedToSession)
{
diff --git a/unittests/dictionary/enchant_dict_check_tests.cpp b/unittests/dictionary/enchant_dict_check_tests.cpp
index 6155639..acf8b59 100644
--- a/unittests/dictionary/enchant_dict_check_tests.cpp
+++ b/unittests/dictionary/enchant_dict_check_tests.cpp
@@ -192,6 +192,13 @@ TEST_FIXTURE(EnchantDictionaryCheck_TestFixture,
CHECK(!dictCheckCalled);
}
+TEST_FIXTURE(EnchantDictionaryCheck_TestFixture,
+ EnchantDictionaryCheck_InvalidUtf8Word_Negative1)
+{
+ CHECK_EQUAL(-1, enchant_dict_check(_dict, "\xa5\xf1\x08", -1));
+ CHECK(!dictCheckCalled);
+}
+
TEST_FIXTURE(EnchantDictionaryCheckNotImplemented_TestFixture,
EnchantDictionaryCheckNotImplemented_Negative1)
{
diff --git a/unittests/dictionary/enchant_dict_is_in_session_tests.cpp b/unittests/dictionary/enchant_dict_is_in_session_tests.cpp
index 5b12beb..e08a5fa 100644
--- a/unittests/dictionary/enchant_dict_is_in_session_tests.cpp
+++ b/unittests/dictionary/enchant_dict_is_in_session_tests.cpp
@@ -112,4 +112,10 @@ TEST_FIXTURE(EnchantDictionaryIsInSession_TestFixture,
EnchantDictionaryIsInSession_WordSize0_0)
{
CHECK_EQUAL(0, enchant_dict_is_in_session(_dict, "hello", 0));
-} \ No newline at end of file
+}
+
+TEST_FIXTURE(EnchantDictionaryIsInSession_TestFixture,
+ EnchantDictionaryIsInSession_InvalidUtf8Word_0)
+{
+ CHECK_EQUAL(0, enchant_dict_is_in_session(_dict, "\xa5\xf1\x08", -1));
+}
diff --git a/unittests/dictionary/enchant_dict_store_replacement_tests.cpp b/unittests/dictionary/enchant_dict_store_replacement_tests.cpp
index a1a7ded..3a8c514 100644
--- a/unittests/dictionary/enchant_dict_store_replacement_tests.cpp
+++ b/unittests/dictionary/enchant_dict_store_replacement_tests.cpp
@@ -187,6 +187,20 @@ TEST_FIXTURE(EnchantDictionaryStoreReplacement_TestFixture,
CHECK(!storeReplacementCalled);
}
+TEST_FIXTURE(EnchantDictionaryStoreReplacement_TestFixture,
+ EnchantDictStoreReplacement_InvalidUtf8Misspelling_DoNothing)
+{
+ enchant_dict_store_replacement(_dict, "\xa5\xf1\x08", -1, "hello", -1);
+ CHECK(!storeReplacementCalled);
+}
+
+TEST_FIXTURE(EnchantDictionaryStoreReplacement_TestFixture,
+ EnchantDictStoreReplacement_InvalidUtf8Correction_DoNothing)
+{
+ enchant_dict_store_replacement(_dict, "helo", -1, "\xa5\xf1\x08", -1);
+ CHECK(!storeReplacementCalled);
+}
+
TEST_FIXTURE(EnchantDictionaryLacksStoreReplacement_TestFixture,
EnchantDictStoreReplacment_ProviderLacksStoreReplacement_DoNothing)
{
diff --git a/unittests/dictionary/enchant_dict_suggest_tests.cpp b/unittests/dictionary/enchant_dict_suggest_tests.cpp
index c6bc4af..d4d3d25 100644
--- a/unittests/dictionary/enchant_dict_suggest_tests.cpp
+++ b/unittests/dictionary/enchant_dict_suggest_tests.cpp
@@ -34,6 +34,7 @@ static enum SuggestBehavior{
returnNull,
returnZero,
returnFour,
+ returnFourOneInvalidUtf8,
} suggestBehavior;
struct EnchantDictionarySuggestTestFixtureBase : EnchantDictionaryTestFixture
@@ -54,7 +55,7 @@ struct EnchantDictionarySuggestTestFixtureBase : EnchantDictionaryTestFixture
FreeStringList(_suggestions);
}
- std::vector<std::string> GetExpectedSuggestions(const std::string& s)
+ std::vector<std::string> GetExpectedSuggestions(const std::string& s, size_t begin = 0)
{
size_t cSuggestions;
char** expectedSuggestions = MockDictionarySuggest (_dict,
@@ -63,8 +64,8 @@ struct EnchantDictionarySuggestTestFixtureBase : EnchantDictionaryTestFixture
&cSuggestions);
std::vector<std::string> result;
- if(expectedSuggestions != NULL){
- result.insert(result.begin(), expectedSuggestions, expectedSuggestions+cSuggestions);
+ if(expectedSuggestions != NULL && begin < cSuggestions){
+ result.insert(result.begin(), expectedSuggestions+begin, expectedSuggestions+cSuggestions);
FreeStringList(expectedSuggestions);
}
@@ -81,18 +82,27 @@ MyMockDictionarySuggest (EnchantDict * dict, const char *const word, size_t len,
dictSuggestCalled = true;
suggestWord = std::string(word,len);
*out_n_suggs = 0;
+ char **sugg_arr = NULL;
switch(suggestBehavior)
{
case returnNull:
- return NULL;
+ sugg_arr = NULL;
+ break;
case returnZero:
- return g_new0 (char *, *out_n_suggs + 1);
+ sugg_arr = g_new0 (char *, *out_n_suggs + 1);
+ break;
case returnFour:
- return MockDictionarySuggest(dict, word, len, out_n_suggs);
+ sugg_arr = MockDictionarySuggest(dict, word, len, out_n_suggs);
+ break;
+ case returnFourOneInvalidUtf8:
+ sugg_arr = MockDictionarySuggest(dict, word, len, out_n_suggs);
+ g_free(sugg_arr[0]);
+ sugg_arr[0] = g_strdup ("\xa5\xf1\x08");
+ break;
}
- return NULL;
+ return sugg_arr;
}
static void
@@ -345,6 +355,17 @@ TEST_FIXTURE(EnchantDictionarySuggest_TestFixture,
CHECK(!providerFreeStringListCalled);
}
+TEST_FIXTURE(EnchantDictionarySuggest_TestFixture,
+ EnchantDictionarySuggest_InvalidUtf8Correction_DoNothing)
+{
+ _suggestions = enchant_dict_suggest(_dict, "\xa5\xf1\x08", -1, NULL);
+
+ CHECK(!_suggestions);
+ CHECK(!dictSuggestCalled);
+ CHECK(!providerFreeStringListCalled);
+}
+
+
TEST_FIXTURE(EnchantDictionarySuggestNotImplemented_TestFixture,
EnchantDictionarySuggestNotImplemented_NullSuggestions)
{
@@ -389,3 +410,24 @@ TEST_FIXTURE(EnchantDictionarySuggest_TestFixture,
CHECK(!providerFreeStringListCalled);
}
+
+TEST_FIXTURE(EnchantDictionarySuggest_TestFixture,
+ EnchantDictionarySuggest_SuggetionListWithInvalidUtf8_InvalidSuggestionIgnored_FreeCalled)
+{
+ suggestBehavior = returnFourOneInvalidUtf8;
+ size_t cSuggestions;
+ _suggestions = enchant_dict_suggest(_dict, "helo", -1, &cSuggestions);
+ CHECK(_suggestions);
+ CHECK(dictSuggestCalled);
+ CHECK(providerFreeStringListCalled);
+
+ CHECK_EQUAL(3, cSuggestions);
+
+ std::vector<std::string> suggestions;
+ if(_suggestions != NULL){
+ suggestions.insert(suggestions.begin(), _suggestions, _suggestions+cSuggestions);
+ }
+
+ CHECK_ARRAY_EQUAL(GetExpectedSuggestions("helo",1), suggestions, std::min((size_t)3,cSuggestions));
+}
+
diff --git a/unittests/provider/enchant_provider_broker_set_error_tests.cpp b/unittests/provider/enchant_provider_broker_set_error_tests.cpp
index f7f490b..84bfe0d 100644
--- a/unittests/provider/enchant_provider_broker_set_error_tests.cpp
+++ b/unittests/provider/enchant_provider_broker_set_error_tests.cpp
@@ -82,6 +82,14 @@ TEST_FIXTURE(EnchantBrokerSetErrorTests,
CHECK_EQUAL(std::string(), GetErrorMessage());
}
+TEST_FIXTURE(EnchantBrokerSetErrorTests,
+ SetErrorMessageOnProvider_InvalidUtf8ErrorMessage_NoErrorSet)
+{
+ enchant_provider_set_error(provider, "\xa5\xf1\x08");
+
+ CHECK_EQUAL(std::string(), GetErrorMessage());
+}
+
TEST_FIXTURE(EnchantBrokerSetErrorTests,
SetErrorMessageOnProvider_MessageCopied)
{
diff --git a/unittests/provider/enchant_provider_dict_set_error_tests.cpp b/unittests/provider/enchant_provider_dict_set_error_tests.cpp
index a8222cc..49144e2 100644
--- a/unittests/provider/enchant_provider_dict_set_error_tests.cpp
+++ b/unittests/provider/enchant_provider_dict_set_error_tests.cpp
@@ -74,6 +74,13 @@ TEST_FIXTURE(EnchantDictionarySetErrorTests,
CHECK_EQUAL(std::string(), GetErrorMessage());
}
+TEST_FIXTURE(EnchantDictionarySetErrorTests,
+ SetErrorMessageOnDictionary_InvalidUtf8ErrorMessage_NoErrorSet)
+{
+ enchant_dict_set_error(_dict, "\xa5\xf1\x08");
+
+ CHECK_EQUAL(std::string(), GetErrorMessage());
+}
TEST_FIXTURE(EnchantDictionarySetErrorTests,
SetErrorMessageOnDictionary_MessageCopied)