Initial Import
[profile/ivi/bundle.git] / TC / unit / utc_ApplicationFW_bundle_iterate_func.c
1 /*
2  *  bundle
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7  * Jaeho Lee <jaeho81.lee@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22 #include <tet_api.h>
23 #include "bundle.h"
24 #include <string.h>
25
26 static void startup(void);
27 static void cleanup(void);
28
29 void (*tet_startup)(void) = startup;
30 void (*tet_cleanup)(void) = cleanup;
31
32 static void utc_ApplicationFW_bundle_iterate_func_01(void);
33 static void utc_ApplicationFW_bundle_iterate_func_02(void);
34
35 enum {
36         POSITIVE_TC_IDX = 0x01,
37         NEGATIVE_TC_IDX,
38 };
39
40 struct tet_testlist tet_testlist[] = {
41         { utc_ApplicationFW_bundle_iterate_func_01, POSITIVE_TC_IDX },
42         { utc_ApplicationFW_bundle_iterate_func_02, NEGATIVE_TC_IDX },
43         { NULL, 0 }
44 };
45
46 static void startup(void)
47 {
48 }
49
50 static void cleanup(void)
51 {
52 }
53
54 static char *cb_val = NULL;
55
56 static void
57 cb_test(const char *k, const char *v, void *data)
58 {
59         cb_val = v;
60 }
61
62 /**
63  * @brief Positive test case of bundle_iterate()
64  */
65 static void utc_ApplicationFW_bundle_iterate_func_01(void)
66 {
67         int r = 0;
68
69         bundle *b = bundle_create();
70         if(!b) {
71                 tet_result(TET_UNINITIATED);
72                 return;
73         }
74         if(bundle_add(b, "a", "123")) {
75                 tet_result(TET_UNINITIATED);
76                 goto cleanup;
77         }
78
79         bundle_iterate(b, cb_test, NULL);
80         if (0 != strcmp(bundle_get_val(b, "a"), cb_val)) {
81                 tet_infoline("bundle_iterate() failed in positive test case");
82                 tet_result(TET_FAIL);
83                 goto cleanup;
84         }
85
86         tet_result(TET_PASS);
87
88 cleanup:
89         if(b) bundle_free(b);
90         return;
91 }
92
93 /**
94  * @brief Negative test case of ug_init bundle_iterate()
95  */
96 static void utc_ApplicationFW_bundle_iterate_func_02(void)
97 {
98         int r = 0;
99
100 /*
101         r = bundle_iterate(...);
102 */
103         if (r) {
104                 tet_infoline("bundle_iterate() failed in negative test case");
105                 tet_result(TET_FAIL);
106                 return;
107         }
108         tet_result(TET_PASS);
109 }