Skip to content

Commit 068b66a

Browse files
committed
Show iniparser_load() copes with quotes, semicolon and hash in attributes
1 parent 62bcf53 commit 068b66a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

test/ressources/quotes.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ string2="str#ing"
55
string3=str"ing
66
string4=str;ing
77
string5=str#ing
8+
str"ing="str\"ing"
9+
"str;ing"="str;ing"
10+
"str#ing"="str#ing"
11+
str:ing="str\"ing"

test/test_iniparser.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,9 @@ void Test_iniparser_quotes(CuTest *tc)
10551055
FILE *ini;
10561056
int ret;
10571057

1058+
/**
1059+
* Test iniparser_load()
1060+
*/
10581061
/* check if section has been written as expected */
10591062
dic = iniparser_load(QUOTES_INI_PATH);
10601063

@@ -1084,7 +1087,24 @@ void Test_iniparser_quotes(CuTest *tc)
10841087
CuAssertStrEquals(tc, "str", iniparser_getstring(dic,
10851088
QUOTES_INI_SEC ":" QUOTES_INI_ATTR5, NULL));
10861089
/*
1087-
* test escaping
1090+
* iniparser_load() supports quotes in attributes
1091+
*/
1092+
CuAssertStrEquals(tc, "str\\", iniparser_getstring(dic,
1093+
QUOTES_INI_SEC ":" "str\"ing", NULL));
1094+
/*
1095+
* iniparser_load() does not support semicolon or hash in attributes
1096+
*/
1097+
CuAssertStrEquals(tc, NULL, iniparser_getstring(dic,
1098+
QUOTES_INI_SEC ":" "str;ing", NULL));
1099+
CuAssertStrEquals(tc, NULL, iniparser_getstring(dic,
1100+
QUOTES_INI_SEC ":" "str#ing", NULL));
1101+
/*
1102+
* iniparser_load() does support colon in attributes
1103+
*/
1104+
CuAssertStrEquals(tc, "str\\", iniparser_getstring(dic,
1105+
QUOTES_INI_SEC ":" "str:ing", NULL));
1106+
/**
1107+
* test iniparser_set()
10881108
*/
10891109
create_empty_ini_file(TMP_INI_PATH);
10901110
dic = iniparser_load(TMP_INI_PATH);

0 commit comments

Comments
 (0)