Fix bugs and add further unittests to `arsd.ini`

This commit is contained in:
Elias Batek 2025-02-07 05:26:39 +01:00
parent 2e12f1a8f5
commit c5406b1634
1 changed files with 21 additions and 2 deletions

23
ini.d
View File

@ -116,7 +116,7 @@ struct IniParser(
}
///
Token front() inout {
inout(Token) front() inout {
return _front;
}
@ -673,7 +673,7 @@ if (isCompatibleString!string) {
alias Section = IniSection!string;
alias KeyValuePair = IniKeyValuePair!string;
auto parser = IniParser!(dialect)(rawIni);
auto parser = IniParser!(dialect, string)(rawIni);
auto document = Document(null);
auto section = Section(null, null);
@ -776,3 +776,22 @@ company = "Digital Mars"
IniKeyValuePair!string("company", "Digital Mars"),
]);
}
@safe unittest {
auto doc = parseIniDocument("");
assert(doc.sections == []);
doc = parseIniDocument(";Comment\n;Comment2\n");
assert(doc.sections == []);
}
@safe unittest {
char[] mutable = ['f', 'o', 'o', '=', 'b', 'a', 'r', '\n'];
auto doc = parseIniDocument(mutable);
assert(doc.sections[0].items[0].key == "foo");
assert(doc.sections[0].items[0].value == "bar");
// is mutable
static assert(is(typeof(doc.sections[0].items[0].value) == char[]));
}