From 70301442a266a0161b63dfb403b09bdc8ba169e3 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Sat, 24 Sep 2022 03:27:41 +0300 Subject: [PATCH] Add additional tests --- source/poodinis/config/dictionary.d | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/poodinis/config/dictionary.d b/source/poodinis/config/dictionary.d index 854e81b..b222776 100644 --- a/source/poodinis/config/dictionary.d +++ b/source/poodinis/config/dictionary.d @@ -381,4 +381,30 @@ version (unittest) { assertThrown!ConfigReadException(dictionary.get("hostname")); } + @("Get value from objects in array") + unittest { + auto dictionary = new ConfigDictionary(); + dictionary.rootNode = new ArrayNode( + new ObjectNode(["wrong": "yes"]), + new ObjectNode(["wrong": "no"]), + new ObjectNode(["wrong": "very"]), + ); + + assert(dictionary.get("[1].wrong") == "no"); + } + + @("Get value from config with mixed types") + unittest { + auto dictionary = new ConfigDictionary(); + dictionary.rootNode = new ObjectNode([ + "uno": cast(ConfigNode) new ValueNode("one"), + "dos": cast(ConfigNode) new ArrayNode(["nope", "two"]), + "tres": cast(ConfigNode) new ObjectNode(["thisone": "three"]) + ]); + + assert(dictionary.get("uno") == "one"); + assert(dictionary.get("dos.[1]") == "two"); + assert(dictionary.get("tres.thisone") == "three"); + } + }