Skip to content

Commit

Permalink
Merge branch 'test_find_entry' of https://github.com/zrrto/iniparser-1
Browse files Browse the repository at this point in the history
…into zrrto-test_find_entry

# Conflicts:
#	test/test_iniparser.c
  • Loading branch information
lmoellendorf committed Mar 2, 2024
2 parents 5ea02a8 + 15659d9 commit 5e5931c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/test_iniparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,3 +962,30 @@ void Test_iniparser_dumpsection_ini(CuTest *tc)
CuAssertStrEquals(tc,"321abc",iniparser_getstring(dic,"section:key1",NULL));
iniparser_freedict(dic);
}

void Test_iniparser_find_entry(CuTest *tc)
{
dictionary *dic;
int i;
/* NULL test */
CuAssertIntEquals(tc, 0, iniparser_find_entry(NULL, NULL));
CuAssertIntEquals(tc, 0, iniparser_find_entry(NULL, "dummy"));

/* Empty dictionary test*/
dic = dictionary_new(10);
CuAssertPtrNotNull(tc, dic);
CuAssertIntEquals(tc, 0, iniparser_find_entry(dic, NULL));
CuAssertIntEquals(tc, 0, iniparser_find_entry(dic, "dummy"));
dictionary_del(dic);

/*Regular dictionary */
dic = generate_dictionary(1, 8);
CuAssertPtrNotNull(tc, dic);
for (i = 1; i < 8; i++)
{
CuAssertIntEquals(tc, 1, iniparser_find_entry(dic, dic->key[i]));
}
CuAssertIntEquals(tc, 0, iniparser_find_entry(dic, "dummy"));

iniparser_freedict(dic);
}

0 comments on commit 5e5931c

Please sign in to comment.