From c5406b1634ab1f50641c6263c4ae3862ff8e5e9d Mon Sep 17 00:00:00 2001 From: Elias Batek Date: Fri, 7 Feb 2025 05:26:39 +0100 Subject: [PATCH] Fix bugs and add further unittests to `arsd.ini` --- ini.d | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ini.d b/ini.d index 9202c1c..57daff1 100644 --- a/ini.d +++ b/ini.d @@ -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[])); +}