Tizen 2.1 base
[external/enchant.git] / unittests / dictionary / enchant_dict_free_string_list_tests.cpp
1 /* Copyright (c) 2007 Eric Scott Albright\r
2  * \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
9  * \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
12  * \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
19  * THE SOFTWARE.\r
20  */\r
21 \r
22 #include <UnitTest++.h>\r
23 #include <enchant.h>\r
24 #include "../EnchantDictionaryTestFixture.h"\r
25 \r
26 struct EnchantDictFreeStringList_TestFixture : EnchantDictionaryTestFixture\r
27 {\r
28     //setup\r
29     EnchantDictFreeStringList_TestFixture()\r
30     {\r
31        _string_list = enchant_dict_suggest (_dict, "foo", -1, NULL);\r
32        _pwl_string_list = enchant_dict_suggest (_pwl, "foo", -1, NULL);\r
33     }\r
34     //Teardown\r
35     ~EnchantDictFreeStringList_TestFixture()\r
36     {\r
37         FreeStringList(_string_list);\r
38         FreeStringList(_pwl_string_list);\r
39     }\r
40     char ** _string_list;\r
41     char ** _pwl_string_list;\r
42 };\r
43 \r
44 /**\r
45  * enchant_dict_free_string_list\r
46  * @dict: A non-null #EnchantDict\r
47  * @string_list: A non-null string list returned from enchant_dict_suggest\r
48  *\r
49  * Releases the string list\r
50  */\r
51 \r
52 /////////////////////////////////////////////////////////////////////////////\r
53 // Test Normal Operation\r
54 TEST_FIXTURE(EnchantDictFreeStringList_TestFixture,\r
55              EnchantDictFreeStringList)\r
56 {\r
57     testResults_;\r
58     enchant_dict_free_string_list(_dict, _string_list);\r
59     _string_list = NULL;\r
60 }\r
61 \r
62 TEST_FIXTURE(EnchantDictFreeStringList_TestFixture,\r
63              EnchantDictFreeStringListOnPwl)\r
64 {\r
65     testResults_;\r
66     enchant_dict_free_string_list(_pwl, _string_list);\r
67     _string_list = NULL;\r
68 }\r
69 \r
70 TEST_FIXTURE(EnchantDictFreeStringList_TestFixture, \r
71              EnchantDictFreeStringList_HasPreviousError_ErrorCleared)\r
72 {\r
73   SetErrorOnMockDictionary("something bad happened");\r
74 \r
75   enchant_dict_free_string_list(_dict, _string_list);\r
76   _string_list = NULL;\r
77 \r
78   CHECK_EQUAL((void*)NULL, (void*)enchant_dict_get_error(_dict));\r
79 }\r
80 \r
81 /////////////////////////////////////////////////////////////////////////////\r
82 // Test Error Conditions\r
83 TEST_FIXTURE(EnchantDictFreeStringList_TestFixture,\r
84              EnchantDictFreeStringList_NullDict_DoNothing)\r
85 {\r
86     testResults_;\r
87     enchant_dict_free_string_list(NULL, _string_list);\r
88 }\r
89 \r
90 TEST_FIXTURE(EnchantDictFreeStringList_TestFixture,\r
91              EnchantDictFreeStringList_NullStringList_DoNothing)\r
92 {\r
93     testResults_;\r
94     enchant_dict_free_string_list(_dict, NULL);\r
95 }\r