[json-glib] Add tests for json paths (2 invalids, 1 valid)



commit 35562f291b7bf1bae88d7e5f78d7be163ca263d6
Author: bi <bisnard antidot net>
Date:   Thu May 16 14:00:03 2013 +0200

    Add tests for json paths (2 invalids, 1 valid)
    
    Signed-off-by: Emmanuele Bassi <ebassi gnome org>
    
    Conflicts:
        json-glib/tests/path.c

 json-glib/tests/path.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/json-glib/tests/path.c b/json-glib/tests/path.c
index 23268d5..0dce631 100644
--- a/json-glib/tests/path.c
+++ b/json-glib/tests/path.c
@@ -45,6 +45,13 @@ static const struct {
   JsonPathError error_code;
 } test_expressions[] = {
   {
+    "INVALID: invalid first character",
+    "/",
+    NULL,
+    FALSE,
+    JSON_PATH_ERROR_INVALID_QUERY,
+  },
+  {
     "INVALID: Invalid character following root",
     "$ponies",
     NULL,
@@ -52,6 +59,13 @@ static const struct {
     JSON_PATH_ERROR_INVALID_QUERY,
   },
   {
+    "INVALID: missing member name or wildcard after dot",
+    "$.store.",
+    NULL,
+    FALSE,
+    JSON_PATH_ERROR_INVALID_QUERY,
+  },
+  {
     "INVALID: Malformed slice (missing step)",
     "$.store.book[0:1:]",
     NULL,
@@ -151,6 +165,16 @@ static const struct {
     "[\"red\",\"19.95\"]",
     TRUE,
   },
+  {
+    "The root node.",
+    "$",
+    "[{\"store\":{\"book\":[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the 
Century\",\"price\":\"8.95\"},"
+                           "{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of 
Honour\",\"price\":\"12.99\"},"
+                           "{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby 
Dick\",\"isbn\":\"0-553-21311-3\",\"price\":\"8.99\"},"
+                           "{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord 
of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":\"22.99\"}],"
+                 "\"bicycle\":{\"color\":\"red\",\"price\":\"19.95\"}}}]",
+    TRUE,
+  }
 };
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]