Skip to content

Commit 5e5931c

Browse files
committed
Merge branch 'test_find_entry' of https://github.com/zrrto/iniparser-1 into zrrto-test_find_entry
# Conflicts: # test/test_iniparser.c
2 parents 5ea02a8 + 15659d9 commit 5e5931c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/test_iniparser.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,3 +962,30 @@ void Test_iniparser_dumpsection_ini(CuTest *tc)
962962
CuAssertStrEquals(tc,"321abc",iniparser_getstring(dic,"section:key1",NULL));
963963
iniparser_freedict(dic);
964964
}
965+
966+
void Test_iniparser_find_entry(CuTest *tc)
967+
{
968+
dictionary *dic;
969+
int i;
970+
/* NULL test */
971+
CuAssertIntEquals(tc, 0, iniparser_find_entry(NULL, NULL));
972+
CuAssertIntEquals(tc, 0, iniparser_find_entry(NULL, "dummy"));
973+
974+
/* Empty dictionary test*/
975+
dic = dictionary_new(10);
976+
CuAssertPtrNotNull(tc, dic);
977+
CuAssertIntEquals(tc, 0, iniparser_find_entry(dic, NULL));
978+
CuAssertIntEquals(tc, 0, iniparser_find_entry(dic, "dummy"));
979+
dictionary_del(dic);
980+
981+
/*Regular dictionary */
982+
dic = generate_dictionary(1, 8);
983+
CuAssertPtrNotNull(tc, dic);
984+
for (i = 1; i < 8; i++)
985+
{
986+
CuAssertIntEquals(tc, 1, iniparser_find_entry(dic, dic->key[i]));
987+
}
988+
CuAssertIntEquals(tc, 0, iniparser_find_entry(dic, "dummy"));
989+
990+
iniparser_freedict(dic);
991+
}

0 commit comments

Comments
 (0)