Tizen 2.0 Release
[framework/appfw/libslp-db-util.git] / TC / unit / utc_ApplicationFW_db_util_open.c
1 /*
2  * libslp-db-util
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include <tet_api.h>
23 #include <db-util.h>
24
25 static void startup(void);
26 static void cleanup(void);
27
28 void (*tet_startup)(void) = startup;
29 void (*tet_cleanup)(void) = cleanup;
30
31 static void utc_ApplicationFW_db_util_open_func_01(void);
32 static void utc_ApplicationFW_db_util_open_func_02(void);
33
34 static sqlite3* db_hd = NULL;
35 char* db_path = "test.db";
36
37 enum {
38         POSITIVE_TC_IDX = 0x01,
39         NEGATIVE_TC_IDX,
40 };
41
42 struct tet_testlist tet_testlist[] = {
43         { utc_ApplicationFW_db_util_open_func_01, POSITIVE_TC_IDX },
44         { utc_ApplicationFW_db_util_open_func_02, NEGATIVE_TC_IDX },
45         { NULL, 0 }
46 };
47
48 static void startup(void)
49 {
50 }
51
52 static void cleanup(void)
53 {
54         db_util_close(db_hd);
55 }
56
57 /**
58  * @brief Positive test case of db_util_open()
59  */
60 static void utc_ApplicationFW_db_util_open_func_01(void)
61 {
62         int r = 0;
63
64         r = db_util_open(db_path, &db_hd, 0);
65         if (r != SQLITE_OK) {
66                 tet_infoline("db_util_open() failed in positive test case");
67                 tet_result(TET_FAIL);
68                 return;
69         }
70
71         tet_result(TET_PASS);
72 }
73
74 /**
75  * @brief Negative test case of ug_init db_util_open()
76  */
77 static void utc_ApplicationFW_db_util_open_func_02(void)
78 {
79         int r = 0;
80
81         r = db_util_open(NULL, &db_hd, 0);
82         if (r == SQLITE_OK) {
83                 tet_infoline("db_util_open() failed in negative test case");
84                 tet_result(TET_FAIL);
85                 return;
86         }
87
88         r = db_util_open(db_path, NULL, 0);
89         if (r == SQLITE_OK) {
90                 tet_infoline("db_util_open() failed in negative test case");
91                 tet_result(TET_FAIL);
92                 return;
93         }
94
95         tet_result(TET_PASS);
96 }