1 #ifndef EnchantBrokerDictExistsTestFixture
\r
2 #error EnchantBrokerDictExistsTestFixture must be defined as the testfixture class to run these tests against
\r
5 #ifndef DictionaryExistsMethodCalled
\r
6 #error DictionaryExistsMethodCalled must be defined as the variable that is set when the method is called
\r
10 * enchant_broker_dict_exists
\r
11 * @broker: A non-null #EnchantBroker
\r
12 * @tag: The non-null language tag you wish to request a dictionary for ("en_US", "de_DE", ...)
\r
14 * language tags are normalized by stripping leading and trailing whitespace,
\r
15 * removing '@' and any trailing characters, removing '.' and any trailing characters,
\r
16 * and replacing '-' with '_'
\r
18 * If no providers have the given language tag, enchant will fallback to the language code
\r
19 * prefix (everything before the first "_")
\r
21 * Return existance of the requested dictionary (1 == true, 0 == false)
\r
24 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
25 EnchantBrokerDictExists_DictDoesNotExist_FalseOnlyAsksOnce)
\r
27 CHECK_EQUAL(0, enchant_broker_dict_exists(_broker, "en"));
\r
28 CHECK_EQUAL(1,DictionaryExistsMethodCalled);
\r
31 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
32 EnchantBrokerDictExists_DictExists_TrueAsksOnce)
\r
34 CHECK_EQUAL(1, enchant_broker_dict_exists(_broker, "en_GB"));
\r
35 CHECK_EQUAL(1,DictionaryExistsMethodCalled);
\r
38 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
39 EnchantBrokerDictExists_BaseDictExists_TrueAsksTwice)
\r
41 CHECK_EQUAL(1, enchant_broker_dict_exists(_broker, "qaa_CA"));
\r
42 CHECK_EQUAL(2,DictionaryExistsMethodCalled);
\r
45 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
46 EnchantBrokerDictExists_ExtraStuffAfterSecondUnderscore_NotStrippedForComparison)
\r
48 CHECK_EQUAL(0, enchant_broker_dict_exists(_broker, "en_GB_special"));
\r
51 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
52 EnchantBrokerDictExists_WhitespaceSurroundingLanguageTag_Removed)
\r
54 CHECK_EQUAL(1, enchant_broker_dict_exists(_broker, "\n\r en_GB \t\f"));
\r
57 /* Vertical tab is not considered to be whitespace in glib!
\r
58 See bug# 59388 http://bugzilla.gnome.org/show_bug.cgi?id=59388
\r
60 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
61 EnchantBrokerDictExists_VerticalTabSurroundingLanguageTag_NotRemoved)
\r
63 CHECK_EQUAL(0, enchant_broker_dict_exists(_broker, "\ven_GB"));
\r
64 CHECK_EQUAL(0, enchant_broker_dict_exists(_broker, "en_GB\v"));
\r
67 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
68 EnchantBrokerDictExists_AtSignInLanguageTag_RemovesToTail)
\r
70 CHECK_EQUAL(1, enchant_broker_dict_exists(_broker, "en_GB@euro"));
\r
73 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
74 EnchantBrokerDictExists_NothingLeftAfterNormalizingLanguageTag_DoesNotCallProvider)
\r
76 CHECK_EQUAL(0, enchant_broker_dict_exists(_broker, "@euro"));
\r
77 CHECK_EQUAL(0,DictionaryExistsMethodCalled);
\r
81 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
82 EnchantBrokerDictExists_PeriodInLanguageTag_RemovesToTail)
\r
84 CHECK_EQUAL(1, enchant_broker_dict_exists(_broker, "en_GB.UTF-8"));
\r
87 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
88 EnchantBrokerDictExists_HyphensInLanguageTag_SubstitutedWithUnderscore)
\r
90 CHECK_EQUAL(1, enchant_broker_dict_exists(_broker, "en-GB"));
\r
93 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
94 EnchantBrokerDictExists_CalledWhenDictionaryIsNotInUse_MakesCall)
\r
96 DictionaryExistsMethodCalled = false;
\r
97 enchant_broker_dict_exists(_broker, "en-GB");
\r
98 CHECK_EQUAL(1,DictionaryExistsMethodCalled);
\r
101 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
102 EnchantBrokerDictExists_DifferentCase_Finds)
\r
104 CHECK_EQUAL(1, enchant_broker_dict_exists(_broker, "EN_gb"));
\r
107 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
108 EnchantBrokerDictExists_DifferentCase_NoRegion_Finds)
\r
110 CHECK_EQUAL(1, enchant_broker_dict_exists(_broker, "QAA"));
\r
114 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
115 EnchantBrokerDictExists_HasPreviousError_ErrorCleared)
\r
117 SetErrorOnMockProvider("something bad happened");
\r
119 enchant_broker_dict_exists(_broker, "en_US");
\r
121 CHECK_EQUAL((void*)NULL, (void*)enchant_broker_get_error(_broker));
\r
124 /////////////////////////////////////////////////////////////////////////////
\r
125 // Test Error Conditions
\r
127 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
128 EnchantBrokerDictExists_NullBroker_0)
\r
130 CHECK_EQUAL(0, enchant_broker_dict_exists (NULL, "en_US"));
\r
133 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
134 EnchantBrokerDictExists_NullTag_0)
\r
136 CHECK_EQUAL(0, enchant_broker_dict_exists (_broker, NULL));
\r
139 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
140 EnchantBrokerDictExists_EmptyTag_0)
\r
142 CHECK_EQUAL(0, enchant_broker_dict_exists (_broker, ""));
\r
145 TEST_FIXTURE(EnchantBrokerDictExistsTestFixture,
\r
146 EnchantBrokerDictExists_InvalidTag_0_ErrorSet)
\r
148 CHECK_EQUAL(0, enchant_broker_dict_exists (_broker, "en~US"));
\r
149 CHECK(NULL != enchant_broker_get_error(_broker));
\r