Tizen 2.1 base
[external/enchant.git] / unittests / dictionary / enchant_dict_get_error_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 /**\r
27  * enchant_dict_get_error\r
28  * @dict: A non-null dictionary\r
29  *\r
30  * Returns a const char string or NULL describing the last exception.\r
31  * WARNING: error is transient. It will likely be cleared as soon as \r
32  * the next dictionary operation is called\r
33  *\r
34  * Returns: an error message\r
35  */\r
36 \r
37 /////////////////////////////////////////////////////////////////////////////\r
38 // Test Normal Operation\r
39 \r
40 TEST_FIXTURE(EnchantDictionaryTestFixture, \r
41              EnchantDictionaryGetError_HasPreviousError_Error)\r
42 {\r
43     std::string errorMessage("something bad happened");\r
44     SetErrorOnMockDictionary(errorMessage);\r
45 \r
46     CHECK_EQUAL(errorMessage.c_str(), enchant_dict_get_error(_dict));\r
47 }\r
48 \r
49 TEST_FIXTURE(EnchantDictionaryTestFixture, \r
50              EnchantDictionaryGetErrorOnPwl_HasPreviousError_Error)\r
51 {\r
52     std::string errorMessage("something bad happened");\r
53     enchant_dict_set_error(_pwl, errorMessage.c_str());\r
54 \r
55 \r
56     CHECK_EQUAL(errorMessage.c_str(), enchant_dict_get_error(_pwl));\r
57 }\r
58 \r
59 TEST_FIXTURE(EnchantDictionaryTestFixture, \r
60              EnchantDictionaryGetError_NoPreviousError_Null)\r
61 {\r
62     CHECK_EQUAL((void*)NULL, (void*)enchant_dict_get_error(_dict));\r
63 }\r
64 \r
65 /////////////////////////////////////////////////////////////////////////////\r
66 // Test Error Conditions\r
67 TEST(EnchantDictionaryGetError_NullBroker_Null)\r
68 {\r
69     CHECK_EQUAL((void*)NULL, (void*)enchant_dict_get_error(NULL));\r
70 }