Signed-off-by: Peter Krempa <pkre...@redhat.com>
---
 .../deflatten-dotted-array-in.json            | 27 ++++++++++++
 .../deflatten-dotted-array-out.json           | 43 +++++++++++++++++++
 tests/virjsontest.c                           |  1 +
 3 files changed, 71 insertions(+)
 create mode 100644 tests/virjsondata/deflatten-dotted-array-in.json
 create mode 100644 tests/virjsondata/deflatten-dotted-array-out.json

diff --git a/tests/virjsondata/deflatten-dotted-array-in.json 
b/tests/virjsondata/deflatten-dotted-array-in.json
new file mode 100644
index 0000000000..06486a8f38
--- /dev/null
+++ b/tests/virjsondata/deflatten-dotted-array-in.json
@@ -0,0 +1,27 @@
+{
+    "valid": {
+        "0": "test",
+        "1": { "something": 123 },
+        "2": true
+    },
+    "outoforder": {
+        "1": { "something": 123 },
+        "2": true,
+        "0": "test"
+    },
+    "invalid-overflow": {
+        "1": { "something": 123 },
+        "2": true,
+        "4": "test"
+    },
+    "invalid-strings": {
+        "1": { "something": 123 },
+        "2": true,
+        "test": "test"
+    },
+    "nestedkeys": {
+        "test.0.test": 123,
+        "test.2.test": 123,
+        "test.1.test": 123
+    }
+}
diff --git a/tests/virjsondata/deflatten-dotted-array-out.json 
b/tests/virjsondata/deflatten-dotted-array-out.json
new file mode 100644
index 0000000000..b32b4b14a9
--- /dev/null
+++ b/tests/virjsondata/deflatten-dotted-array-out.json
@@ -0,0 +1,43 @@
+{
+  "valid": [
+    "test",
+    {
+      "something": 123
+    },
+    true
+  ],
+  "outoforder": [
+    "test",
+    {
+      "something": 123
+    },
+    true
+  ],
+  "invalid-overflow": {
+    "1": {
+      "something": 123
+    },
+    "2": true,
+    "4": "test"
+  },
+  "invalid-strings": {
+    "1": {
+      "something": 123
+    },
+    "2": true,
+    "test": "test"
+  },
+  "nestedkeys": {
+    "test": [
+      {
+        "test": 123
+      },
+      {
+        "test": 123
+      },
+      {
+        "test": 123
+      }
+    ]
+  }
+}
diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index 9da0f9c90d..77ca6b449b 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -609,6 +609,7 @@ mymain(void)
     DO_TEST_DEFLATTEN("concat", true);
     DO_TEST_DEFLATTEN("concat-double-key", false);
     DO_TEST_DEFLATTEN("qemu-sheepdog", true);
+    DO_TEST_DEFLATTEN("dotted-array", true);

     return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
2.24.1

Reply via email to