]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: virjson: Modify logic in testJSONFromString
authorPeter Krempa <pkrempa@redhat.com>
Mon, 3 Jul 2017 13:02:38 +0000 (15:02 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 19 Jul 2017 13:24:10 +0000 (15:24 +0200)
To allow better testing in case where the string was parsed, modify the
logic so that the regular code path is not included in a conditional
block.

tests/virjsontest.c

index b9c2106207130b476f342673ce4c1b3b3e371b53..a5ffc47074992d197ff40ef52feb0912a1d32395 100644 (file)
@@ -27,24 +27,24 @@ testJSONFromString(const void *data)
 
     json = virJSONValueFromString(info->doc);
 
-    if (info->pass) {
-        if (!json) {
+    if (!json) {
+        if (info->pass) {
             VIR_TEST_VERBOSE("Fail to parse %s\n", info->doc);
-            ret = -1;
-            goto cleanup;
-        } else {
-            VIR_TEST_DEBUG("Parsed %s\n", info->doc);
-        }
-    } else {
-        if (json) {
-            VIR_TEST_VERBOSE("Should not have parsed %s\n", info->doc);
-            ret = -1;
             goto cleanup;
         } else {
             VIR_TEST_DEBUG("Fail to parse %s\n", info->doc);
+            ret = 0;
+            goto cleanup;
         }
     }
 
+    if (!info->pass) {
+        VIR_TEST_VERBOSE("Should not have parsed %s\n", info->doc);
+        goto cleanup;
+    }
+
+    VIR_TEST_DEBUG("Parsed %s\n", info->doc);
+
     ret = 0;
 
  cleanup: