From 5d31192edbdd316df3f8ac5ba44a0f8195fcde60 Mon Sep 17 00:00:00 2001 From: Elias Batek Date: Sun, 16 Feb 2025 21:35:39 +0100 Subject: [PATCH] Add `parseIniMergedAA` example --- ini.d | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ini.d b/ini.d index 6314d8c..f4d83af 100644 --- a/ini.d +++ b/ini.d @@ -106,6 +106,26 @@ module arsd.ini; assert(icon == "setup.exe,0"); } +/// +@safe unittest { + // INI example data (e.g. from an `autorun.inf` file) + static immutable string rawIniData = + "[autorun]\n" + ~ "open=setup.exe\n" + ~ "icon=setup.exe,0\n"; + + // Parse the document into a flat associative array. + // (Sections would get merged, but there is only one section in the + // example anyway.) + string[string] data = parseIniMergedAA(rawIniData); + + string open = data["open"]; + string icon = data["icon"]; + + assert(open == "setup.exe"); + assert(icon == "setup.exe,0"); +} + /// @safe unittest { // INI example data (e.g. from an `autorun.inf` file):