1 /* Copyright (c) 2008 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 "enchant.h"
\r
23 #include "enchant-provider.h"
\r
26 EnchantProvider* GetProviderForTests();
\r
27 char* GetErrorMessage(EnchantProvider* provider);
\r
29 struct Provider_TestFixture
\r
31 EnchantProvider* _provider;
\r
34 Provider_TestFixture()
\r
36 _provider = GetProviderForTests();
\r
39 ~Provider_TestFixture()
\r
43 std::string Convert(const std::wstring & ws)
\r
45 gchar* str = g_utf16_to_utf8((gunichar2*)ws.c_str(), (glong)ws.length(), NULL, NULL, NULL);
\r
51 std::wstring Convert(const std::string & s)
\r
53 gunichar2* str = g_utf8_to_utf16(s.c_str(), (glong)s.length(), NULL, NULL, NULL);
\r
54 std::wstring ws((wchar_t*)str);
\r
59 EnchantDict* GetFirstAvailableDictionary()
\r
61 EnchantDict* dict=NULL;
\r
63 // get the first dictionary listed as being available
\r
64 if(_provider->list_dicts && _provider->request_dict)
\r
68 char ** dicts = (*_provider->list_dicts) (_provider, &n_dicts);
\r
69 for (size_t i = 0; i < n_dicts; i++)
\r
71 dict = (*_provider->request_dict) (_provider, dicts[i]);
\r
74 if (dicts && _provider->free_string_list)
\r
76 (*_provider->free_string_list) (_provider, dicts);
\r
82 EnchantDict* GetDictionary(const char* language)
\r
84 if(_provider->request_dict)
\r
86 return (*_provider->request_dict) (_provider, language);
\r
91 virtual void ReleaseDictionary(EnchantDict* dict)
\r
93 if (dict && _provider->dispose_dict)
\r
95 _provider->dispose_dict(_provider, dict);
\r