TEST_FIXTURE(EnchantDictionarySetErrorTests, SetErrorMessageOnDictionary_InvalidUtf8ErrorMessage_NoErrorSet) { enchant_dict_set_error(_dict, "\xa5\xf1\x08"); CHECK_EQUAL(std::string(), GetErrorMessage()); }
TEST_FIXTURE(EnchantDictionarySetErrorTests, SetErrorMessageOnDictionary_NullError_NoErrorSet) { enchant_dict_set_error(_dict, NULL); CHECK_EQUAL(std::string(), GetErrorMessage()); }
///////////////////////////////////////////////////////////////////////////// // Test Error Conditions TEST_FIXTURE(EnchantDictionarySetErrorTests, SetErrorMessageOnDictionary_NullDictionary_NoErrorSet) { enchant_dict_set_error(NULL, "Error message to display"); CHECK_EQUAL(std::string(), GetErrorMessage()); }
TEST_FIXTURE(EnchantDictionarySetErrorTests, SetErrorMessageOnDictionary) { std::string expectedErrorMessage("Error message to display"); enchant_dict_set_error(_dict, expectedErrorMessage.c_str()); CHECK_EQUAL(expectedErrorMessage, GetErrorMessage()); }
TEST_FIXTURE(EnchantDictionarySetErrorTests, SetErrorMessageOnDictionary_MessageCopied) { std::string expectedErrorMessage("Error message to display"); enchant_dict_set_error(_dict, expectedErrorMessage.c_str()); expectedErrorMessage[0] = 'e'; CHECK(expectedErrorMessage != GetErrorMessage()); }
TEST_FIXTURE(EnchantDictionaryTestFixture, EnchantDictionaryGetErrorOnPwl_HasPreviousError_Error) { std::string errorMessage("something bad happened"); enchant_dict_set_error(_pwl, errorMessage.c_str()); CHECK_EQUAL(errorMessage.c_str(), enchant_dict_get_error(_pwl)); }
static int aspell_dict_check (EnchantDict * me, const char *const word, size_t len) { PspellManager *manager; int val; char *normalizedWord; manager = (PspellManager *) me->user_data; normalizedWord = g_utf8_normalize (word, len, G_NORMALIZE_NFC); val = pspell_manager_check (manager, normalizedWord, strlen(normalizedWord)); g_free(normalizedWord); if (val == 0) return 1; else if (val > 0) return 0; else { enchant_dict_set_error (me, pspell_manager_error_message (manager)); return -1; } }