summaryrefslogtreecommitdiffstats
path: root/common/ini/ini_config_ut.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-04-08 17:27:44 -0400
committerSimo Sorce <ssorce@redhat.com>2009-04-09 15:52:48 -0400
commit329651039032f044b4e1e13d0fc338e4d174b980 (patch)
tree107ef60b024fd3bc84256898eb7b349ff09bea15 /common/ini/ini_config_ut.c
parent0c7bc8d567fa099ebd0d23978176dfb4a2dc9007 (diff)
downloadsssd-329651039032f044b4e1e13d0fc338e4d174b980.tar.gz
sssd-329651039032f044b4e1e13d0fc338e4d174b980.tar.xz
sssd-329651039032f044b4e1e13d0fc338e4d174b980.zip
INI component: Fixed issues introduced by cleanup.
Added a few new functions. Cleaned code that was subject to conditional build. Fixed the floating point conversion. Keep const values as const.
Diffstat (limited to 'common/ini/ini_config_ut.c')
-rw-r--r--common/ini/ini_config_ut.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/common/ini/ini_config_ut.c b/common/ini/ini_config_ut.c
index 642f268b3..4968a0ac2 100644
--- a/common/ini/ini_config_ut.c
+++ b/common/ini/ini_config_ut.c
@@ -217,6 +217,8 @@ int get_test()
unsigned long number_ulong;
unsigned char logical;
char *str;
+ const char *cstr;
+ const char *cstrn;
void *binary;
int length;
int i;
@@ -224,6 +226,7 @@ int get_test()
char **strptr;
int size;
long *array;
+ double *darray;
printf("\n\n===== GET TEST START ======\n");
printf("Reading collection\n");
@@ -298,9 +301,8 @@ int get_test()
/* Get a string without duplicication */
/* Negative test */
- error = 0;
- str = get_string_config_value(NULL, 0, &error);
- if(!error) {
+ cstrn = get_const_string_config_value(NULL, NULL);
+ if(cstrn != NULL) {
printf("Expected error got success.\n");
destroy_collection(ini_config);
return -1;
@@ -310,21 +312,21 @@ int get_test()
/* Now get string from the right item */
error = 0;
- str = get_string_config_value(item, 0, &error);
+ cstr = get_const_string_config_value(item, &error);
if(error) {
printf("Expected success got error %d.\n",error);
destroy_collection(ini_config);
return error;
}
- printf("Value: [%s]\n",str);
+ printf("Value: [%s]\n",cstr);
/* Same thing but create a dup */
printf("Get item as string with duplication from correct item.\n");
error = 0;
- str = get_string_config_value(item, 1, &error);
+ str = get_string_config_value(item, &error);
if(error) {
printf("Expected success got error %d.\n",error);
destroy_collection(ini_config);
@@ -677,6 +679,39 @@ int get_test()
free_long_config_array(array);
+ printf("Get double array item\n");
+
+ item = (struct collection_item *)(NULL);
+ error = get_config_item("domains/EXAMPLE.COM","double_array", ini_config, &item);
+ if(error) {
+ printf("Expected success but got error! %d\n",error);
+ destroy_collection(ini_config);
+ return error;
+ }
+
+ /* Item should be found */
+ if(item == (struct collection_item *)(NULL)) {
+ printf("Expected success but got NULL.\n");
+ destroy_collection(ini_config);
+ return -1;
+ }
+
+ debug_item(item);
+
+ error = 0;
+ size = 0; /* Here size is not optional!!! */
+ darray = get_double_config_array(item, &size, &error);
+ if(error) {
+ printf("Expect success got error %d.\n",error);
+ destroy_collection(ini_config);
+ return error;
+ }
+
+ /* Can be used with this cycle */
+ for(i=0;i<size;i++) printf("%.4f\n",darray[i]);
+
+ free_double_config_array(darray);
+
printf("Done with get test!\n");
return EOK;
}