• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Virtual machine Management Terminal User Interface


コミットメタ情報

リビジョン8406742cb0610c312b809b3b615ad52291c82c48 (tree)
日時2022-08-11 22:34:50
作者Koine Yuusuke(koinec) <koinec@user...>
コミッターKoine Yuusuke(koinec)

ログメッセージ

WorkBackup (Testing for keyval.[ch])

変更サマリ

差分

--- a/src/keyval.c
+++ b/src/keyval.c
@@ -29,24 +29,18 @@
2929 #define VMTUI_SRC_KEYVAL
3030 #include "vmtui.h"
3131
32+/* ===========================================================================*/
3233 /*
3334 clear
34-delete
35-modify
3635 */
3736
3837 /* ===========================================================================*/
39-/* ===========================================================================*/
40-/* ===========================================================================*/
41-/* ===========================================================================*/
42-
43-/* ===========================================================================*/
4438 VMTUI_KEYVAL_EXTERN
4539 KeyVal_Item *
4640 KeyVal_SearchItem(
4741 KeyVal_Info *p_kvinfo,
4842 char *pstr_key,
49- KeyVal_Item *p_parent ) {
43+ int i_parent ) {
5044
5145 int i_cnt;
5246 DWord dw_hash;
@@ -65,7 +59,7 @@ KeyVal_Item *
6559 for( i_cnt = 0; i_cnt < p_kvinfo->i_used; i_cnt++ ) {
6660 p_item = (p_kvinfo->p_items + i_cnt);
6761
68- if(( NULL != p_parent ) && ( p_item->pv_parent != (void *)p_parent ))
62+ if( p_item->i_parent != i_parent )
6963 { continue; }
7064
7165 if( p_item->dw_keyhash == dw_hash ) {
@@ -83,23 +77,33 @@ VMTUI_KEYVAL_EXTERN
8377 KeyVal_Data *
8478 KeyVal_GetData(
8579 KeyVal_Info *p_kvinfo,
86- char *pstr_key,
87- KeyVal_Item *p_parent ) {
80+ char *pstr_fullkey ) {
8881
89- KeyVal_Item *p_item;
82+ char str_key[(KEYVAL_MAXLEN_KEY * KEYVAL_MAXDEPTH_KEY) + 1];
83+ char *pstr_next;
84+ char *pstr_now;
85+ KeyVal_Item *p_item = NULL;
86+ int i_parent = KEYVAL_NONEID;
9087
9188 if( NULL == p_kvinfo ) {
9289 return NULL;
9390 }
9491
95- if( NULL == pstr_key ) {
92+ if( NULL == pstr_fullkey ) {
9693 return NULL;
9794 }
9895
99- p_item = KeyVal_SearchItem( p_kvinfo, pstr_key, p_parent );
100- if( NULL == p_item ) {
101- return NULL;
102- }
96+ strncpy( str_key, pstr_fullkey, (KEYVAL_MAXLEN_KEY * KEYVAL_MAXDEPTH_KEY) + 1 );
97+
98+ pstr_next = str_key;
99+ do {
100+ pstr_now = strsep( &pstr_next, "/" );
101+ p_item = KeyVal_SearchItem( p_kvinfo, pstr_now, i_parent );
102+ if( NULL != p_item )
103+ { i_parent = (int)(p_item - p_kvinfo->p_items); }
104+ }while(( NULL != pstr_next ) || ( NULL == p_item ) );
105+
106+ if( NULL == p_item ) { return NULL; }
103107
104108 return &(p_item->value);
105109 }
@@ -111,21 +115,23 @@ int
111115 KeyVal_Info *p_kvinfo,
112116 char *pstr_key,
113117 KeyVal_Data *p_value,
114- KeyVal_Item *p_parent ) {
118+ int i_parent ) {
115119
120+ int i_id;
121+ int i_cnt;
116122 int i_allocs;
117123 KeyVal_Item *p_item;
118124
119125 if( NULL == p_kvinfo ) {
120- return -0x01;
126+ return -0x02;
121127 }
122128
123129 if( NULL == pstr_key ) {
124- return -0x02;
130+ return -0x03;
125131 }
126132
127133 if( NULL == p_value ) {
128- return -0x03;
134+ return -0x04;
129135 }
130136
131137 // Extend Item Memory ---
@@ -133,7 +139,7 @@ int
133139 i_allocs = p_kvinfo->i_allocs + KEYVAL_DEFAULT_ALLOCS;
134140 p_item = (KeyVal_Item *)realloc( p_kvinfo->p_items, i_allocs );
135141 if( NULL == p_item ) {
136- return -0x04;
142+ return -0x05;
137143 }
138144
139145 memset( (p_item + p_kvinfo->i_allocs), 0x00, sizeof( KeyVal_Info ) * KEYVAL_DEFAULT_ALLOCS );
@@ -145,16 +151,23 @@ int
145151 }
146152
147153 // Check duplicate key ---
148- p_item = KeyVal_SearchItem( p_kvinfo, pstr_key, p_parent );
154+ p_item = KeyVal_SearchItem( p_kvinfo, pstr_key, i_parent );
149155
150156 if( NULL == p_item ) {
151- // Append Value ----
152- p_item = (p_kvinfo->p_items + p_kvinfo->i_used);
157+ for( i_cnt = 0; i_cnt < p_kvinfo->i_used; i_cnt++ ) {
158+ p_item = (p_kvinfo->p_items + i_cnt);
159+ if( IS_KEYVAL_TYPE_NONE( p_item->value ) ) { break; }
160+ }
153161
154- p_kvinfo->i_used++;
162+ if( i_cnt == p_kvinfo->i_used ) {
163+ // Append Value ----
164+ p_item = (p_kvinfo->p_items + p_kvinfo->i_used);
165+
166+ p_kvinfo->i_used++;
167+ }
155168
156169 // Set Key string ---
157- strncpy( p_item->str_key, pstr_key, sizeof( KEYVAL_MAXLEN_KEY ) );
170+ strncpy( p_item->str_key, pstr_key, KEYVAL_MAXLEN_KEY );
158171 p_item->dw_keyhash = Common_CalcDJBhash( pstr_key );
159172 }
160173
@@ -162,11 +175,99 @@ int
162175
163176 memcpy( &(p_item->value), p_value, sizeof( KeyVal_Data ) );
164177
165- p_item->pv_parent = (void *)p_parent;
178+ p_item->i_parent = i_parent;
166179
167- return 0x00;
180+ i_id = (int)(p_item - p_kvinfo->p_items);
181+
182+ return i_id;
168183 }
169184
185+/* ===========================================================================*/
186+VMTUI_KEYVAL_EXTERN
187+int
188+ KeyVal_SetData(
189+ KeyVal_Info *p_kvinfo,
190+ char *pstr_fullkey,
191+ KeyVal_Data *p_value ) {
192+
193+ char str_key[(KEYVAL_MAXLEN_KEY * KEYVAL_MAXDEPTH_KEY) + 1];
194+ char *pstr_next;
195+ char *pstr_now;
196+ int i_parent = KEYVAL_NONEID;
197+ int i_id;
198+ KeyVal_Data t_parent;
199+
200+ if( NULL == p_kvinfo ) {
201+ return -0x02;
202+ }
203+
204+ if( NULL == pstr_fullkey ) {
205+ return -0x03;
206+ }
207+
208+ t_parent.b_type = KEYVAL_TYPE_PARENT;
209+
210+ strncpy( str_key, pstr_fullkey, (KEYVAL_MAXLEN_KEY * KEYVAL_MAXDEPTH_KEY) + 1 );
211+
212+ pstr_next = str_key;
213+ do {
214+ pstr_now = strsep( &pstr_next, "/" );
215+ //p_item = KeyVal_SearchItem( p_kvinfo, pstr_now, i_parent );
216+
217+ if( NULL == pstr_next ) {
218+ i_id = KeyVal_RegistData( p_kvinfo, pstr_now, p_value, i_parent );
219+ }
220+ else {
221+ i_parent = KeyVal_RegistData( p_kvinfo, pstr_now, &t_parent, i_parent );
222+ }
223+
224+ }while(( NULL != pstr_next ) || ( KEYVAL_NONEID > i_id ) || ( KEYVAL_NONEID > i_parent ) );
225+
226+ return i_id;
227+}
228+
229+/* ===========================================================================*/
230+VMTUI_KEYVAL_EXTERN
231+int
232+ KeyVal_RemoveData(
233+ KeyVal_Info *p_kvinfo,
234+ char *pstr_key,
235+ int i_parent ) {
236+
237+ int i_id;
238+ int i_cnt;
239+ KeyVal_Item *p_item;
240+ KeyVal_Item *p_now;
241+
242+ if( NULL == p_kvinfo ) {
243+ return -0x02;
244+ }
245+
246+ if( NULL == pstr_key ) {
247+ return -0x03;
248+ }
249+
250+ p_item = KeyVal_SearchItem( p_kvinfo, pstr_key, i_parent );
251+ if( NULL == p_item ) {
252+ return -0x04;
253+ }
254+ i_id = (int)(p_item - p_kvinfo->p_items);
255+
256+ for( i_cnt = 0; i_cnt < p_kvinfo->i_used; i_cnt++ ) {
257+ p_now = (p_kvinfo->p_items + i_cnt);
258+
259+ if( i_id == p_now->i_parent ) {
260+ KeyVal_RemoveData( p_kvinfo, p_now->str_key, i_id );
261+ }
262+ }
263+
264+ p_item->value.b_type = KEYVAL_TYPE_NONE;
265+ p_item->i_parent = KEYVAL_NONEID;
266+ p_item->dw_keyhash = 0x00;
267+ p_item->str_key[0] = '\0';
268+
269+ return 0x00;
270+}
170271
171272 /* ===========================================================================*/
172273 VMTUI_KEYVAL_EXTERN
--- a/src/keyval.h
+++ b/src/keyval.h
@@ -32,16 +32,20 @@
3232
3333 #define KEYVAL_DEFAULT_ALLOCS 128
3434 #define KEYVAL_MAXLEN_KEY 64
35+#define KEYVAL_MAXDEPTH_KEY 4
3536 #define KEYVAL_MAXLEN_STRVAL 256
3637
38+#define KEYVAL_NONEID -0x01
39+
3740 typedef struct {
3841 Byte b_type;
3942
4043 #define KEYVAL_TYPE_NONE 0x00
41- #define KEYVAL_TYPE_INT 0x01
42- #define KEYVAL_TYPE_DWORD 0x02
43- #define KEYVAL_TYPE_STRING 0x03
44- #define KEYVAL_TYPE_STRPTR 0x04
44+ #define KEYVAL_TYPE_PARENT 0x01
45+ #define KEYVAL_TYPE_INT 0x02
46+ #define KEYVAL_TYPE_DWORD 0x03
47+ #define KEYVAL_TYPE_STRING 0x04
48+ #define KEYVAL_TYPE_STRPTR 0x05
4549
4650 union {
4751 int i_val;
@@ -53,6 +57,8 @@ typedef struct {
5357
5458 #define IS_KEYVAL_TYPE_NONE(n) (KEYVAL_TYPE_NONE==((n).b_type))
5559 #define IS_KEYVAL_TYPE_NONE_P(n) (KEYVAL_TYPE_NONE==((n)->b_type))
60+#define IS_KEYVAL_TYPE_PARENT(n) (KEYVAL_TYPE_PARENT==((n).b_type))
61+#define IS_KEYVAL_TYPE_PARENT_P(n) (KEYVAL_TYPE_PARENT==((n)->b_type))
5662 #define IS_KEYVAL_TYPE_INT(n) (KEYVAL_TYPE_INT==((n).b_type))
5763 #define IS_KEYVAL_TYPE_INT_P(n) (KEYVAL_TYPE_INT==((n)->b_type))
5864 #define IS_KEYVAL_TYPE_DWORD(n) (KEYVAL_TYPE_DWORD==((n).b_type))
@@ -67,13 +73,16 @@ typedef struct {
6773 #define KEYVAL_DATA_STR(n) (n).str_val
6874 #define KEYVAL_DATA_STR_P(n) (n)->str_val
6975
76+#define KEYVAL_DATA_SET_INT(n,v) (n).b_type=KEYVAL_TYPE_INT, (n).i_val=(v)
77+#define KEYVAL_DATA_SET_INT_P(n,v) (n)->b_type=KEYVAL_TYPE_INT, (n)->i_val=(v)
78+
7079 typedef struct {
7180 DWord dw_keyhash;
7281 char str_key[KEYVAL_MAXLEN_KEY];
7382
7483 KeyVal_Data value;
7584
76- void *pv_parent;
85+ int i_parent;
7786
7887 } KeyVal_Item;
7988
@@ -89,14 +98,15 @@ typedef struct {
8998 #define VMTUI_KEYVAL_EXTERN extern
9099 #endif
91100 VMTUI_KEYVAL_EXTERN KeyVal_Item *KeyVal_SearchItem(
92- KeyVal_Info *p_kvinfo, char *pstr_key,
93- KeyVal_Item *p_parent );
101+ KeyVal_Info *p_kvinfo, char *pstr_key, int i_parent );
94102 VMTUI_KEYVAL_EXTERN KeyVal_Data *KeyVal_GetData(
95- KeyVal_Info *p_kvinfo, char *pstr_key,
96- KeyVal_Item *p_parent );
103+ KeyVal_Info *p_kvinfo, char *pstr_fullkey );
97104 VMTUI_KEYVAL_EXTERN int KeyVal_RegistData(
98105 KeyVal_Info *p_kvinfo, char *pstr_key,
99- KeyVal_Data *p_value, KeyVal_Item *p_parent );
106+ KeyVal_Data *p_value, int i_parent );
107+VMTUI_KEYVAL_EXTERN int KeyVal_SetData(
108+ KeyVal_Info *p_kvinfo, char *pstr_fullkey, KeyVal_Data *p_value );
109+VMTUI_KEYVAL_EXTERN int KeyVal_RemoveData( KeyVal_Info *p_kvinfo, char *pstr_key, int i_parent );
100110 VMTUI_KEYVAL_EXTERN int KeyVal_Init( KeyVal_Info *p_keyval, int i_allocs );
101111 VMTUI_KEYVAL_EXTERN int KeyVal_Term( KeyVal_Info *p_keyval );
102112
--- a/src/test_keyval.c
+++ b/src/test_keyval.c
@@ -84,6 +84,673 @@ void
8484 return;
8585 }
8686
87+/* ===========================================================================*/
88+void
89+ Test_KeyVal_RegistData_001( void ) {
90+
91+ // for RegistData / SearchItem / RemoveData Basical Test ---
92+
93+ int i_id;
94+ int i_err;
95+ KeyVal_Info t_keyval;
96+ KeyVal_Data t_data;
97+ KeyVal_Item *p_item;
98+
99+ i_err = KeyVal_Init( &t_keyval, 0 );
100+ CU_ASSERT( 0x00 == i_err );
101+
102+ CU_ASSERT( KEYVAL_DEFAULT_ALLOCS == t_keyval.i_allocs );
103+ CU_ASSERT( 0 == t_keyval.i_used );
104+ CU_ASSERT( NULL != t_keyval.p_items );
105+
106+ // Phase 1 ----
107+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
108+ CU_ASSERT( NULL == p_item );
109+
110+ KEYVAL_DATA_SET_INT(t_data, 12345678 );
111+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
112+ i_id = KeyVal_RegistData( &t_keyval, "test0", &t_data, KEYVAL_NONEID );
113+ CU_ASSERT( 0 == i_id );
114+
115+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
116+ CU_ASSERT( NULL != p_item );
117+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
118+ CU_ASSERT( 12345678 == KEYVAL_DATA_INT( p_item->value ) );
119+
120+ i_err = KeyVal_RemoveData( &t_keyval, "test0", KEYVAL_NONEID );
121+ CU_ASSERT( 0x00 == i_err );
122+
123+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
124+ CU_ASSERT( NULL == p_item );
125+
126+ // Phase 2 ----
127+ KEYVAL_DATA_SET_INT(t_data, 12345678 );
128+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
129+ i_id = KeyVal_RegistData( &t_keyval, "test1", &t_data, KEYVAL_NONEID );
130+ CU_ASSERT( 0 == i_id );
131+
132+ KEYVAL_DATA_SET_INT(t_data, 87654321 );
133+ i_id = KeyVal_RegistData( &t_keyval, "test0", &t_data, KEYVAL_NONEID );
134+ CU_ASSERT( 1 == i_id );
135+
136+ KEYVAL_DATA_SET_INT(t_data, 22222222 );
137+ i_id = KeyVal_RegistData( &t_keyval, "test2222", &t_data, KEYVAL_NONEID );
138+ CU_ASSERT( 2 == i_id );
139+
140+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
141+ CU_ASSERT( NULL != p_item );
142+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
143+ CU_ASSERT( 87654321 == KEYVAL_DATA_INT( p_item->value ) );
144+
145+ p_item = KeyVal_SearchItem( &t_keyval, "test2222", KEYVAL_NONEID );
146+ CU_ASSERT( NULL != p_item );
147+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
148+ CU_ASSERT( 22222222 == KEYVAL_DATA_INT( p_item->value ) );
149+
150+ p_item = KeyVal_SearchItem( &t_keyval, "test1", KEYVAL_NONEID );
151+ CU_ASSERT( NULL != p_item );
152+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
153+ CU_ASSERT( 12345678 == KEYVAL_DATA_INT( p_item->value ) );
154+
155+ i_err = KeyVal_RemoveData( &t_keyval, "test0", KEYVAL_NONEID );
156+ CU_ASSERT( 0x00 == i_err );
157+
158+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
159+ CU_ASSERT( NULL == p_item );
160+
161+ p_item = KeyVal_SearchItem( &t_keyval, "test1", KEYVAL_NONEID );
162+ CU_ASSERT( NULL != p_item );
163+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
164+ CU_ASSERT( 12345678 == KEYVAL_DATA_INT( p_item->value ) );
165+
166+ p_item = KeyVal_SearchItem( &t_keyval, "test2222", KEYVAL_NONEID );
167+ CU_ASSERT( NULL != p_item );
168+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
169+ CU_ASSERT( 22222222 == KEYVAL_DATA_INT( p_item->value ) );
170+
171+ KEYVAL_DATA_SET_INT(t_data, 87654321 );
172+ i_id = KeyVal_RegistData( &t_keyval, "test0", &t_data, KEYVAL_NONEID );
173+ CU_ASSERT( 1 == i_id );
174+
175+ KEYVAL_DATA_SET_INT(t_data, 88888888 );
176+ i_id = KeyVal_RegistData( &t_keyval, "test0", &t_data, KEYVAL_NONEID );
177+ CU_ASSERT( 1 == i_id );
178+
179+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
180+ CU_ASSERT( NULL != p_item );
181+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
182+ CU_ASSERT( 88888888 == KEYVAL_DATA_INT( p_item->value ) );
183+
184+ i_err = KeyVal_RemoveData( &t_keyval, "test1", KEYVAL_NONEID );
185+ CU_ASSERT( 0x00 == i_err );
186+
187+ i_err = KeyVal_RemoveData( &t_keyval, "test0", KEYVAL_NONEID );
188+ CU_ASSERT( 0x00 == i_err );
189+
190+ i_err = KeyVal_RemoveData( &t_keyval, "test2222", KEYVAL_NONEID );
191+ CU_ASSERT( 0x00 == i_err );
192+
193+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
194+ CU_ASSERT( NULL == p_item );
195+
196+ p_item = KeyVal_SearchItem( &t_keyval, "test1", KEYVAL_NONEID );
197+ CU_ASSERT( NULL == p_item );
198+
199+ p_item = KeyVal_SearchItem( &t_keyval, "test2222", KEYVAL_NONEID );
200+ CU_ASSERT( NULL == p_item );
201+
202+ i_err = KeyVal_Term( &t_keyval );
203+ CU_ASSERT( 0x00 == i_err );
204+
205+ CU_ASSERT( 0 == t_keyval.i_allocs );
206+ CU_ASSERT( 0 == t_keyval.i_used );
207+ CU_ASSERT( NULL == t_keyval.p_items );
208+
209+ return;
210+}
211+
212+/* ===========================================================================*/
213+void
214+ Test_KeyVal_RegistData_002( void ) {
215+
216+ // for RegistData / SearchItem / RemoveData Depth Test ---
217+
218+ int i_id;
219+ int i_err;
220+ KeyVal_Info t_keyval;
221+ KeyVal_Data t_data;
222+ KeyVal_Item *p_item;
223+
224+ i_err = KeyVal_Init( &t_keyval, 0 );
225+ CU_ASSERT( 0x00 == i_err );
226+
227+ CU_ASSERT( KEYVAL_DEFAULT_ALLOCS == t_keyval.i_allocs );
228+ CU_ASSERT( 0 == t_keyval.i_used );
229+ CU_ASSERT( NULL != t_keyval.p_items );
230+
231+ // Phase 1 ----
232+ KEYVAL_DATA_SET_INT(t_data, 0 );
233+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
234+ i_id = KeyVal_RegistData( &t_keyval, "depth0", &t_data, KEYVAL_NONEID );
235+ CU_ASSERT( 0 == i_id );
236+
237+ KEYVAL_DATA_SET_INT(t_data, 11 );
238+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
239+ i_id = KeyVal_RegistData( &t_keyval, "depth1", &t_data, 0 );
240+ CU_ASSERT( 1 == i_id );
241+
242+ KEYVAL_DATA_SET_INT(t_data, 222 );
243+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
244+ i_id = KeyVal_RegistData( &t_keyval, "depth2", &t_data, 1 );
245+ CU_ASSERT( 2 == i_id );
246+
247+ KEYVAL_DATA_SET_INT(t_data, 3333 );
248+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
249+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 2 );
250+ CU_ASSERT( 3 == i_id );
251+
252+ KEYVAL_DATA_SET_INT(t_data, 44444 );
253+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
254+ i_id = KeyVal_RegistData( &t_keyval, "depth4", &t_data, 3 );
255+ CU_ASSERT( 4 == i_id );
256+
257+ KEYVAL_DATA_SET_INT(t_data, 3 );
258+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
259+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, KEYVAL_NONEID );
260+ CU_ASSERT( 5 == i_id );
261+
262+ KEYVAL_DATA_SET_INT(t_data, 33 );
263+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
264+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 0 );
265+ CU_ASSERT( 6 == i_id );
266+
267+ KEYVAL_DATA_SET_INT(t_data, 333 );
268+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
269+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 1 );
270+ CU_ASSERT( 7 == i_id );
271+
272+ KEYVAL_DATA_SET_INT(t_data, 33333 );
273+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
274+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 3 );
275+ CU_ASSERT( 8 == i_id );
276+
277+
278+ // Check Depth 0 ---
279+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", KEYVAL_NONEID );
280+ CU_ASSERT( NULL != p_item );
281+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
282+ CU_ASSERT( 0 == KEYVAL_DATA_INT( p_item->value ) );
283+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", KEYVAL_NONEID );
284+ CU_ASSERT( NULL == p_item );
285+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", KEYVAL_NONEID );
286+ CU_ASSERT( NULL == p_item );
287+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", KEYVAL_NONEID );
288+ CU_ASSERT( NULL != p_item );
289+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
290+ CU_ASSERT( 3 == KEYVAL_DATA_INT( p_item->value ) );
291+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", KEYVAL_NONEID );
292+ CU_ASSERT( NULL == p_item );
293+
294+ // Check Depth 1 ---
295+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", 0 );
296+ CU_ASSERT( NULL == p_item );
297+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 0 );
298+ CU_ASSERT( NULL != p_item );
299+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
300+ CU_ASSERT( 11 == KEYVAL_DATA_INT( p_item->value ) );
301+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 0 );
302+ CU_ASSERT( NULL == p_item );
303+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 0 );
304+ CU_ASSERT( NULL != p_item );
305+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
306+ CU_ASSERT( 33 == KEYVAL_DATA_INT( p_item->value ) );
307+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 0 );
308+ CU_ASSERT( NULL == p_item );
309+
310+ // Check Depth 2 ---
311+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", 1 );
312+ CU_ASSERT( NULL == p_item );
313+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 1 );
314+ CU_ASSERT( NULL == p_item );
315+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 1 );
316+ CU_ASSERT( NULL != p_item );
317+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
318+ CU_ASSERT( 222 == KEYVAL_DATA_INT( p_item->value ) );
319+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 1 );
320+ CU_ASSERT( NULL != p_item );
321+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
322+ CU_ASSERT( 333 == KEYVAL_DATA_INT( p_item->value ) );
323+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 1 );
324+ CU_ASSERT( NULL == p_item );
325+
326+ // Check Depth 3 ---
327+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", 2 );
328+ CU_ASSERT( NULL == p_item );
329+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 2 );
330+ CU_ASSERT( NULL == p_item );
331+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 2 );
332+ CU_ASSERT( NULL == p_item );
333+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 2 );
334+ CU_ASSERT( NULL != p_item );
335+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
336+ CU_ASSERT( 3333 == KEYVAL_DATA_INT( p_item->value ) );
337+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 2 );
338+ CU_ASSERT( NULL == p_item );
339+
340+ // Check Depth 4 ---
341+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", 3 );
342+ CU_ASSERT( NULL == p_item );
343+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 3 );
344+ CU_ASSERT( NULL == p_item );
345+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 3 );
346+ CU_ASSERT( NULL == p_item );
347+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 3 );
348+ CU_ASSERT( NULL != p_item );
349+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
350+ CU_ASSERT( 33333 == KEYVAL_DATA_INT( p_item->value ) );
351+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 3 );
352+ CU_ASSERT( NULL != p_item );
353+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
354+ CU_ASSERT( 44444 == KEYVAL_DATA_INT( p_item->value ) );
355+
356+
357+ // Delete & Check Depth 4 ---
358+ i_err = KeyVal_RemoveData( &t_keyval, "depth3", 3 );
359+ CU_ASSERT( 0x00 == i_err );
360+
361+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", KEYVAL_NONEID );
362+ CU_ASSERT( NULL != p_item );
363+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
364+ CU_ASSERT( 3 == KEYVAL_DATA_INT( p_item->value ) );
365+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 0 );
366+ CU_ASSERT( NULL != p_item );
367+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
368+ CU_ASSERT( 33 == KEYVAL_DATA_INT( p_item->value ) );
369+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 1 );
370+ CU_ASSERT( NULL != p_item );
371+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
372+ CU_ASSERT( 333 == KEYVAL_DATA_INT( p_item->value ) );
373+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 2 );
374+ CU_ASSERT( NULL != p_item );
375+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
376+ CU_ASSERT( 3333 == KEYVAL_DATA_INT( p_item->value ) );
377+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 3 );
378+ CU_ASSERT( NULL == p_item );
379+
380+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 3 );
381+ CU_ASSERT( NULL != p_item );
382+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
383+ CU_ASSERT( 44444 == KEYVAL_DATA_INT( p_item->value ) );
384+
385+ // Delete & Check Depth 3 ---
386+ i_err = KeyVal_RemoveData( &t_keyval, "depth3", 2 );
387+ CU_ASSERT( 0x00 == i_err );
388+
389+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", KEYVAL_NONEID );
390+ CU_ASSERT( NULL != p_item );
391+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
392+ CU_ASSERT( 3 == KEYVAL_DATA_INT( p_item->value ) );
393+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 0 );
394+ CU_ASSERT( NULL != p_item );
395+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
396+ CU_ASSERT( 33 == KEYVAL_DATA_INT( p_item->value ) );
397+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 1 );
398+ CU_ASSERT( NULL != p_item );
399+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
400+ CU_ASSERT( 333 == KEYVAL_DATA_INT( p_item->value ) );
401+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 2 );
402+ CU_ASSERT( NULL == p_item );
403+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 3 );
404+ CU_ASSERT( NULL == p_item );
405+
406+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 3 );
407+ CU_ASSERT( NULL == p_item );
408+
409+ // Delete & Check Depth 2 ---
410+ i_err = KeyVal_RemoveData( &t_keyval, "depth3", 1 );
411+ CU_ASSERT( 0x00 == i_err );
412+
413+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", KEYVAL_NONEID );
414+ CU_ASSERT( NULL != p_item );
415+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
416+ CU_ASSERT( 3 == KEYVAL_DATA_INT( p_item->value ) );
417+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 0 );
418+ CU_ASSERT( NULL != p_item );
419+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
420+ CU_ASSERT( 33 == KEYVAL_DATA_INT( p_item->value ) );
421+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 1 );
422+ CU_ASSERT( NULL == p_item );
423+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 2 );
424+ CU_ASSERT( NULL == p_item );
425+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 3 );
426+ CU_ASSERT( NULL == p_item );
427+
428+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 1 );
429+ CU_ASSERT( NULL != p_item );
430+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
431+ CU_ASSERT( 222 == KEYVAL_DATA_INT( p_item->value ) );
432+
433+ // Delete & Check Depth 1 ---
434+ i_err = KeyVal_RemoveData( &t_keyval, "depth3", 0 );
435+ CU_ASSERT( 0x00 == i_err );
436+
437+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", KEYVAL_NONEID );
438+ CU_ASSERT( NULL != p_item );
439+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
440+ CU_ASSERT( 3 == KEYVAL_DATA_INT( p_item->value ) );
441+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 0 );
442+ CU_ASSERT( NULL == p_item );
443+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 1 );
444+ CU_ASSERT( NULL == p_item );
445+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 2 );
446+ CU_ASSERT( NULL == p_item );
447+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 3 );
448+ CU_ASSERT( NULL == p_item );
449+
450+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 1 );
451+ CU_ASSERT( NULL != p_item );
452+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
453+ CU_ASSERT( 222 == KEYVAL_DATA_INT( p_item->value ) );
454+
455+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 0 );
456+ CU_ASSERT( NULL != p_item );
457+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
458+ CU_ASSERT( 11 == KEYVAL_DATA_INT( p_item->value ) );
459+
460+ i_err = KeyVal_RemoveData( &t_keyval, "depth1", 0 );
461+ CU_ASSERT( 0x00 == i_err );
462+
463+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 0 );
464+ CU_ASSERT( NULL == p_item );
465+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 1 );
466+ CU_ASSERT( NULL == p_item );
467+
468+ // Delete & Check Depth 0 ---
469+ i_err = KeyVal_RemoveData( &t_keyval, "depth3", KEYVAL_NONEID );
470+ CU_ASSERT( 0x00 == i_err );
471+
472+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", KEYVAL_NONEID );
473+ CU_ASSERT( NULL == p_item );
474+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 0 );
475+ CU_ASSERT( NULL == p_item );
476+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 1 );
477+ CU_ASSERT( NULL == p_item );
478+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 2 );
479+ CU_ASSERT( NULL == p_item );
480+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 3 );
481+ CU_ASSERT( NULL == p_item );
482+
483+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", KEYVAL_NONEID );
484+ CU_ASSERT( NULL != p_item );
485+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
486+ CU_ASSERT( 0 == KEYVAL_DATA_INT( p_item->value ) );
487+
488+ i_err = KeyVal_RemoveData( &t_keyval, "depth0", KEYVAL_NONEID );
489+ CU_ASSERT( 0x00 == i_err );
490+
491+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", KEYVAL_NONEID );
492+ CU_ASSERT( NULL == p_item );
493+
494+
495+ // Phase 2 ----
496+ KEYVAL_DATA_SET_INT(t_data, 0 );
497+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
498+ i_id = KeyVal_RegistData( &t_keyval, "depth0", &t_data, KEYVAL_NONEID );
499+ CU_ASSERT( 0 == i_id );
500+
501+ KEYVAL_DATA_SET_INT(t_data, 11 );
502+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
503+ i_id = KeyVal_RegistData( &t_keyval, "depth1", &t_data, 0 );
504+ CU_ASSERT( 1 == i_id );
505+
506+ KEYVAL_DATA_SET_INT(t_data, 222 );
507+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
508+ i_id = KeyVal_RegistData( &t_keyval, "depth2", &t_data, 1 );
509+ CU_ASSERT( 2 == i_id );
510+
511+ KEYVAL_DATA_SET_INT(t_data, 3333 );
512+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
513+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 2 );
514+ CU_ASSERT( 3 == i_id );
515+
516+ KEYVAL_DATA_SET_INT(t_data, 44444 );
517+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
518+ i_id = KeyVal_RegistData( &t_keyval, "depth4", &t_data, 3 );
519+ CU_ASSERT( 4 == i_id );
520+
521+ KEYVAL_DATA_SET_INT(t_data, 3 );
522+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
523+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, KEYVAL_NONEID );
524+ CU_ASSERT( 5 == i_id );
525+
526+ KEYVAL_DATA_SET_INT(t_data, 33 );
527+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
528+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 0 );
529+ CU_ASSERT( 6 == i_id );
530+
531+ KEYVAL_DATA_SET_INT(t_data, 333 );
532+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
533+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 1 );
534+ CU_ASSERT( 7 == i_id );
535+
536+ KEYVAL_DATA_SET_INT(t_data, 33333 );
537+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
538+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 3 );
539+ CU_ASSERT( 8 == i_id );
540+
541+
542+ i_err = KeyVal_RemoveData( &t_keyval, "depth0", KEYVAL_NONEID );
543+ CU_ASSERT( 0x00 == i_err );
544+
545+ // Check Depth 0 ---
546+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", KEYVAL_NONEID );
547+ CU_ASSERT( NULL == p_item );
548+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", KEYVAL_NONEID );
549+ CU_ASSERT( NULL == p_item );
550+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", KEYVAL_NONEID );
551+ CU_ASSERT( NULL == p_item );
552+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", KEYVAL_NONEID );
553+ CU_ASSERT( NULL != p_item );
554+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
555+ CU_ASSERT( 3 == KEYVAL_DATA_INT( p_item->value ) );
556+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", KEYVAL_NONEID );
557+ CU_ASSERT( NULL == p_item );
558+
559+ // Check Depth 1 ---
560+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", 0 );
561+ CU_ASSERT( NULL == p_item );
562+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 0 );
563+ CU_ASSERT( NULL == p_item );
564+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 0 );
565+ CU_ASSERT( NULL == p_item );
566+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 0 );
567+ CU_ASSERT( NULL == p_item );
568+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 0 );
569+ CU_ASSERT( NULL == p_item );
570+
571+ // Check Depth 2 ---
572+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", 1 );
573+ CU_ASSERT( NULL == p_item );
574+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 1 );
575+ CU_ASSERT( NULL == p_item );
576+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 1 );
577+ CU_ASSERT( NULL == p_item );
578+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 1 );
579+ CU_ASSERT( NULL == p_item );
580+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 1 );
581+ CU_ASSERT( NULL == p_item );
582+
583+ // Check Depth 3 ---
584+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", 2 );
585+ CU_ASSERT( NULL == p_item );
586+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 2 );
587+ CU_ASSERT( NULL == p_item );
588+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 2 );
589+ CU_ASSERT( NULL == p_item );
590+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 2 );
591+ CU_ASSERT( NULL == p_item );
592+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 2 );
593+ CU_ASSERT( NULL == p_item );
594+
595+ // Check Depth 4 ---
596+ p_item = KeyVal_SearchItem( &t_keyval, "depth0", 3 );
597+ CU_ASSERT( NULL == p_item );
598+ p_item = KeyVal_SearchItem( &t_keyval, "depth1", 3 );
599+ CU_ASSERT( NULL == p_item );
600+ p_item = KeyVal_SearchItem( &t_keyval, "depth2", 3 );
601+ CU_ASSERT( NULL == p_item );
602+ p_item = KeyVal_SearchItem( &t_keyval, "depth3", 3 );
603+ CU_ASSERT( NULL == p_item );
604+ p_item = KeyVal_SearchItem( &t_keyval, "depth4", 3 );
605+ CU_ASSERT( NULL == p_item );
606+
607+
608+ // Phase 3 ----
609+ KEYVAL_DATA_SET_INT(t_data, 0 );
610+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
611+ i_id = KeyVal_RegistData( &t_keyval, "depth0", &t_data, KEYVAL_NONEID );
612+ CU_ASSERT( 0 == i_id );
613+
614+ KEYVAL_DATA_SET_INT(t_data, 11 );
615+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
616+ i_id = KeyVal_RegistData( &t_keyval, "depth1", &t_data, 0 );
617+ CU_ASSERT( 1 == i_id );
618+
619+ KEYVAL_DATA_SET_INT(t_data, 222 );
620+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
621+ i_id = KeyVal_RegistData( &t_keyval, "depth2", &t_data, 1 );
622+ CU_ASSERT( 2 == i_id );
623+
624+ KEYVAL_DATA_SET_INT(t_data, 3333 );
625+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
626+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 2 );
627+ CU_ASSERT( 3 == i_id );
628+
629+ KEYVAL_DATA_SET_INT(t_data, 44444 );
630+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
631+ i_id = KeyVal_RegistData( &t_keyval, "depth4", &t_data, 3 );
632+ CU_ASSERT( 4 == i_id );
633+
634+ KEYVAL_DATA_SET_INT(t_data, 3 );
635+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
636+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, KEYVAL_NONEID );
637+ CU_ASSERT( 5 == i_id );
638+
639+ KEYVAL_DATA_SET_INT(t_data, 33 );
640+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
641+ i_id = KeyVal_RegistData( &t_keyval, "depth3", &t_data, 0 );
642+ CU_ASSERT( 6 == i_id );
643+
644+
645+ i_err = KeyVal_Term( &t_keyval );
646+ CU_ASSERT( 0x00 == i_err );
647+
648+ CU_ASSERT( 0 == t_keyval.i_allocs );
649+ CU_ASSERT( 0 == t_keyval.i_used );
650+ CU_ASSERT( NULL == t_keyval.p_items );
651+
652+ return;
653+}
654+
655+/* ===========================================================================*/
656+void
657+ Test_KeyVal_RegistData_003( void ) {
658+
659+ // for RegistData / SearchItem / RemoveData DataType Variation Test ---
660+
661+ int i_id;
662+ int i_err;
663+ KeyVal_Info t_keyval;
664+ KeyVal_Data t_data;
665+ KeyVal_Item *p_item;
666+
667+ i_err = KeyVal_Init( &t_keyval, 0 );
668+ CU_ASSERT( 0x00 == i_err );
669+
670+ CU_ASSERT( KEYVAL_DEFAULT_ALLOCS == t_keyval.i_allocs );
671+ CU_ASSERT( 0 == t_keyval.i_used );
672+ CU_ASSERT( NULL != t_keyval.p_items );
673+
674+ // Phase 1 ----
675+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
676+ CU_ASSERT( NULL == p_item );
677+
678+ KEYVAL_DATA_SET_INT(t_data, 12345678 );
679+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
680+ i_id = KeyVal_RegistData( &t_keyval, "test0", &t_data, KEYVAL_NONEID );
681+ CU_ASSERT( 0 == i_id );
682+
683+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
684+ CU_ASSERT( NULL != p_item );
685+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
686+ CU_ASSERT( 12345678 == KEYVAL_DATA_INT( p_item->value ) );
687+
688+ i_err = KeyVal_RemoveData( &t_keyval, "test0", KEYVAL_NONEID );
689+ CU_ASSERT( 0x00 == i_err );
690+
691+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
692+ CU_ASSERT( NULL == p_item );
693+
694+
695+ i_err = KeyVal_Term( &t_keyval );
696+ CU_ASSERT( 0x00 == i_err );
697+
698+ CU_ASSERT( 0 == t_keyval.i_allocs );
699+ CU_ASSERT( 0 == t_keyval.i_used );
700+ CU_ASSERT( NULL == t_keyval.p_items );
701+
702+ return;
703+}
704+
705+/* ===========================================================================*/
706+void
707+ Test_KeyVal_RegistData_004( void ) {
708+
709+ // for RegistData / SearchItem / RemoveData Item Limit Extension Test ---
710+
711+ int i_id;
712+ int i_err;
713+ KeyVal_Info t_keyval;
714+ KeyVal_Data t_data;
715+ KeyVal_Item *p_item;
716+
717+ i_err = KeyVal_Init( &t_keyval, 0 );
718+ CU_ASSERT( 0x00 == i_err );
719+
720+ CU_ASSERT( KEYVAL_DEFAULT_ALLOCS == t_keyval.i_allocs );
721+ CU_ASSERT( 0 == t_keyval.i_used );
722+ CU_ASSERT( NULL != t_keyval.p_items );
723+
724+ // Phase 1 ----
725+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
726+ CU_ASSERT( NULL == p_item );
727+
728+ KEYVAL_DATA_SET_INT(t_data, 12345678 );
729+ CU_ASSERT( IS_KEYVAL_TYPE_INT( t_data ));
730+ i_id = KeyVal_RegistData( &t_keyval, "test0", &t_data, KEYVAL_NONEID );
731+ CU_ASSERT( 0 == i_id );
732+
733+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
734+ CU_ASSERT( NULL != p_item );
735+ CU_ASSERT( IS_KEYVAL_TYPE_INT( p_item->value ) );
736+ CU_ASSERT( 12345678 == KEYVAL_DATA_INT( p_item->value ) );
737+
738+ i_err = KeyVal_RemoveData( &t_keyval, "test0", KEYVAL_NONEID );
739+ CU_ASSERT( 0x00 == i_err );
740+
741+ p_item = KeyVal_SearchItem( &t_keyval, "test0", KEYVAL_NONEID );
742+ CU_ASSERT( NULL == p_item );
743+
744+
745+ i_err = KeyVal_Term( &t_keyval );
746+ CU_ASSERT( 0x00 == i_err );
747+
748+ CU_ASSERT( 0 == t_keyval.i_allocs );
749+ CU_ASSERT( 0 == t_keyval.i_used );
750+ CU_ASSERT( NULL == t_keyval.p_items );
751+
752+ return;
753+}
87754
88755 /* ===========================================================================*/
89756 VMTUI_TEST_KEYVAL_EXTERN
@@ -96,6 +763,10 @@ int
96763 pt_keyval = CU_add_suite( "VMTUI_KeyVal", NULL, NULL );
97764
98765 CU_add_test( pt_keyval, "VMTUI_KeyVal_InitTerm_001", Test_KeyVal_InitTerm_001 );
766+ CU_add_test( pt_keyval, "VMTUI_KeyVal_RegistData_001", Test_KeyVal_RegistData_001 );
767+ CU_add_test( pt_keyval, "VMTUI_KeyVal_RegistData_002", Test_KeyVal_RegistData_002 );
768+ CU_add_test( pt_keyval, "VMTUI_KeyVal_RegistData_003", Test_KeyVal_RegistData_003 );
769+ CU_add_test( pt_keyval, "VMTUI_KeyVal_RegistData_004", Test_KeyVal_RegistData_004 );
99770
100771 return 0x00;
101772 }