1 /* Copyright (c) 2007 Eric Scott Albright
\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
10 * The above copyright notice and this permission notice shall be included in
\r
11 * all copies or substantial portions of the Software.
\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
22 #include <UnitTest++.h>
\r
23 #include <enchant.h>
\r
24 #include "../EnchantDictionaryTestFixture.h"
\r
26 struct EnchantDictionaryIsAdded_TestFixture : EnchantDictionaryTestFixture
\r
30 * enchant_dict_is_added
\r
31 * @dict: A non-null #EnchantDict
\r
32 * @word: The word you wish to see if it's in your session
\r
33 * @len: the byte length of @word, or -1 for strlen (@word)
\r
36 /////////////////////////////////////////////////////////////////////////////
\r
37 // Test Normal Operation
\r
38 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
39 EnchantDictionaryIsAdded_AddedToSession_1)
\r
41 enchant_dict_add_to_session(_dict, "hello", -1);
\r
43 CHECK_EQUAL(1, enchant_dict_is_added(_dict, "hello", -1));
\r
46 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
47 EnchantDictionaryIsAdded_Added_1)
\r
49 enchant_dict_add(_dict, "hello", -1);
\r
51 CHECK_EQUAL(1, enchant_dict_is_added(_dict, "hello", -1));
\r
54 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
55 EnchantDictionaryIsAdded_NotAdded_0)
\r
57 CHECK_EQUAL(0, enchant_dict_is_added(_dict, "hello", -1));
\r
60 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
61 EnchantDictionaryIsAdded_OnBrokerPwl_AddedToSession_1)
\r
63 enchant_dict_add_to_session(_pwl, "hello", -1);
\r
65 CHECK_EQUAL(1, enchant_dict_is_added(_pwl, "hello", -1));
\r
68 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
69 EnchantDictionaryIsAdded_OnBrokerPwl_Added_1)
\r
71 enchant_dict_add(_pwl, "hello", -1);
\r
73 CHECK_EQUAL(1, enchant_dict_is_added(_pwl, "hello", -1));
\r
76 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
77 EnchantDictionaryIsAdded_OnBrokerPwl_NotAdded_0)
\r
79 CHECK_EQUAL(0, enchant_dict_is_added(_pwl, "hello", -1));
\r
82 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
83 EnchantDictionaryIsAdded_HasPreviousError_ErrorCleared)
\r
85 SetErrorOnMockDictionary("something bad happened");
\r
87 enchant_dict_is_added(_dict, "hello", -1);
\r
88 CHECK_EQUAL((void*)NULL, (void*)enchant_dict_get_error(_dict));
\r
91 /////////////////////////////////////////////////////////////////////////////
\r
92 // Test Error Conditions
\r
93 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
94 EnchantDictionaryIsAdded_NullDictionary_0)
\r
96 CHECK_EQUAL(0, enchant_dict_is_added(NULL, "hello", -1));
\r
99 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
100 EnchantDictionaryIsAdded_NullWord_0)
\r
102 CHECK_EQUAL(0, enchant_dict_is_added(_dict, NULL, -1));
\r
105 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
106 EnchantDictionaryIsAdded_EmptyWord_0)
\r
108 CHECK_EQUAL(0, enchant_dict_is_added(_dict, "", -1));
\r
111 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
112 EnchantDictionaryIsAdded_WordSize0_0)
\r
114 CHECK_EQUAL(0, enchant_dict_is_added(_dict, "hello", 0));
\r
117 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
118 EnchantDictionaryIsAdded_InvalidUtf8Word_0)
\r
120 CHECK_EQUAL(0, enchant_dict_is_added(_dict, "\xa5\xf1\x08", -1));
\r
123 TEST_FIXTURE(EnchantDictionaryIsAdded_TestFixture,
\r
124 EnchantDictionaryIsAdded_WordExistsInPwlAndExclude_0)
\r
126 ExternalAddWordToDictionary("hello");
\r
127 ExternalAddWordToExclude("hello");
\r
129 ReloadTestDictionary();
\r
130 CHECK_EQUAL(0, enchant_dict_is_added(_dict, "hello", -1));
\r