summaryrefslogtreecommitdiffstats
path: root/ini/ini_config_ut.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-07-17 19:22:13 -0400
committerSimo Sorce <ssorce@redhat.com>2009-07-20 10:50:51 -0400
commit407d6c9c673af8c1cd19b97e2530d004ccb18213 (patch)
tree8dc60d7f0c4594f12a970990e15d6a1d9496eae1 /ini/ini_config_ut.c
parent02e0ff6aa48e362d0af4cc69983a070bd53a70c2 (diff)
downloadding-libs-407d6c9c673af8c1cd19b97e2530d004ccb18213.tar.gz
ding-libs-407d6c9c673af8c1cd19b97e2530d004ccb18213.tar.xz
ding-libs-407d6c9c673af8c1cd19b97e2530d004ccb18213.zip
COLLECTION & INI Cleanup
I started to cleanup the unit tests from the type cust around NULL and found several problems that I had to address: 1) The choice of the "." as a search separator turned out to be a poor choice. The problem was that the file name has "." and INI was relaying on files to be used as property names. I corrected that part in the INI but after discussion with Simo we decided to switch from "." to "!" as special symbol anyways. 2) Found that the property rename was not reinitializing the hash. Corrected. Added ticket to add unit tests around it (#83).
Diffstat (limited to 'ini/ini_config_ut.c')
-rw-r--r--ini/ini_config_ut.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/ini/ini_config_ut.c b/ini/ini_config_ut.c
index bcb47e6..3ce08ae 100644
--- a/ini/ini_config_ut.c
+++ b/ini/ini_config_ut.c
@@ -217,7 +217,7 @@ int real_test(const char *file)
}
/* Are we done ? */
- if (item == (struct collection_item *)(NULL)) break;
+ if (item == NULL) break;
type = col_get_item_type(item);
@@ -246,9 +246,9 @@ int get_test(void)
{
int error;
- struct collection_item *ini_config = (struct collection_item *)(NULL);
- struct collection_item *error_set = (struct collection_item *)(NULL);
- struct collection_item *item = (struct collection_item *)(NULL);
+ struct collection_item *ini_config = NULL;
+ struct collection_item *error_set = NULL;
+ struct collection_item *item = NULL;
int number;
long number_long;
double number_double;
@@ -286,7 +286,7 @@ int get_test(void)
printf("Negtive test - trying to get non existing key-value pair.\n");
/* Negative test */
- item = (struct collection_item *)(NULL);
+ item = NULL;
error = get_config_item("monitor1", "description1", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
@@ -295,14 +295,14 @@ int get_test(void)
}
/* Item should not be found */
- if (item != (struct collection_item *)(NULL)) {
+ if (item != NULL) {
printf("Expected NULL but got something else!\n");
free_ini_config(ini_config);
return -1;
}
/* Another negative test but section exists this time */
- item = (struct collection_item *)(NULL);
+ item = NULL;
error = get_config_item("monitor", "description1", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
@@ -311,7 +311,7 @@ int get_test(void)
}
/* Item should not be found */
- if(item != (struct collection_item *)(NULL)) {
+ if(item != NULL) {
printf("Expected NULL but got something else!\n");
free_ini_config(ini_config);
return -1;
@@ -320,7 +320,7 @@ int get_test(void)
printf("Trying to get an item.\n");
/* Positive test */
- item = (struct collection_item *)(NULL);
+ item = NULL;
error = get_config_item("monitor", "description", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
@@ -329,7 +329,7 @@ int get_test(void)
}
/* Item should be found */
- if (item == (struct collection_item *)(NULL)) {
+ if (item == NULL) {
printf("Expected item but got something NULL!\n");
free_ini_config(ini_config);
return -1;
@@ -380,7 +380,7 @@ int get_test(void)
/* Get a badly formated number */
printf("Convert item to number with strict conversion.\n");
- item = (struct collection_item *)(NULL);
+ item = NULL;
error = get_config_item("monitor", "bad_number", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
@@ -389,7 +389,7 @@ int get_test(void)
}
/* Item should be found */
- if (item == (struct collection_item *)(NULL)) {
+ if (item == NULL) {
printf("Expected item but got something NULL!\n");
free_ini_config(ini_config);
return -1;
@@ -434,7 +434,7 @@ int get_test(void)
printf("Fetch another item from section \"domains/LOCAL\" named \"enumerate\".\n");
- item = (struct collection_item *)(NULL);
+ item = NULL;
error = get_config_item("domains/LOCAL","enumerate", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
@@ -443,7 +443,7 @@ int get_test(void)
}
/* Item should be found */
- if (item == (struct collection_item *)(NULL)) {
+ if (item == NULL) {
printf("Expected success but got NULL.\n");
free_ini_config(ini_config);
return -1;
@@ -563,7 +563,7 @@ int get_test(void)
/* Get real bool item and convert it */
printf("Get real bool item \"legacy\" and convert it.\n");
- item = (struct collection_item *)(NULL);
+ item = NULL;
error = get_config_item("domains/LOCAL","legacy", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n",error);
@@ -572,7 +572,7 @@ int get_test(void)
}
/* Item should be found */
- if (item == (struct collection_item *)(NULL)) {
+ if (item == NULL) {
printf("Expected success but got NULL.\n");
free_ini_config(ini_config);
return -1;
@@ -597,7 +597,7 @@ int get_test(void)
printf("Get binary item\n");
- item = (struct collection_item *)(NULL);
+ item = NULL;
error = get_config_item("domains/EXAMPLE.COM","binary_test", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
@@ -606,7 +606,7 @@ int get_test(void)
}
/* Item should be found */
- if (item == (struct collection_item *)(NULL)) {
+ if (item == NULL) {
printf("Expected success but got NULL.\n");
free_ini_config(ini_config);
return -1;
@@ -632,7 +632,7 @@ int get_test(void)
printf("Get string array item\n");
- item = (struct collection_item *)(NULL);
+ item = NULL;
error = get_config_item("domains", "domainsorder", ini_config, &item);
if(error) {
printf("Expected success but got error! %d\n",error);
@@ -641,7 +641,7 @@ int get_test(void)
}
/* Item should be found */
- if (item == (struct collection_item *)(NULL)) {
+ if (item == NULL) {
printf("Expected success but got NULL.\n");
free_ini_config(ini_config);
return -1;
@@ -686,7 +686,7 @@ int get_test(void)
printf("Get long array item\n");
- item = (struct collection_item *)(NULL);
+ item = NULL;
error = get_config_item("domains/EXAMPLE.COM", "long_array", ini_config, &item);
if(error) {
printf("Expected success but got error! %d\n", error);
@@ -695,7 +695,7 @@ int get_test(void)
}
/* Item should be found */
- if (item == (struct collection_item *)(NULL)) {
+ if (item == NULL) {
printf("Expected success but got NULL.\n");
free_ini_config(ini_config);
return -1;
@@ -719,7 +719,7 @@ int get_test(void)
printf("Get double array item\n");
- item = (struct collection_item *)(NULL);
+ 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);
@@ -728,7 +728,7 @@ int get_test(void)
}
/* Item should be found */
- if (item == (struct collection_item *)(NULL)) {
+ if (item == NULL) {
printf("Expected success but got NULL.\n");
free_ini_config(ini_config);
return -1;
@@ -800,14 +800,14 @@ int get_test(void)
int main(int argc, char *argv[])
{
- int error;
-
- char *srcdir;
+ int error = EOK;
+ char *srcdir = NULL;
srcdir = getenv("srcdir");
if(srcdir) {
- if(chdir(srcdir) == 0) {
+ if(chdir(srcdir) != 0) {
error = errno;
+ printf("Failed to change directory, error %d\n", error);
return error;
}
}