summaryrefslogtreecommitdiff
path: root/src/json_test.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-02-07 19:19:53 +0100
committerBram Moolenaar <Bram@vim.org>2016-02-07 19:19:53 +0100
commit595e64e259faefb330866852e1b9f6168544572a (patch)
tree87986bc108647e7c597195cea325ca130db69a40 /src/json_test.c
parent55fab439a6f3bba6dbe780ac034b84d5822a1a96 (diff)
downloadvim-git-595e64e259faefb330866852e1b9f6168544572a.tar.gz
patch 7.4.1279v7.4.1279
Problem: jsonencode() is not producing strict JSON. Solution: Add jsencode() and jsdecode(). Make jsonencode() and jsondecode() strict.
Diffstat (limited to 'src/json_test.c')
-rw-r--r--src/json_test.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/src/json_test.c b/src/json_test.c
index f50c95608..2a28c7405 100644
--- a/src/json_test.c
+++ b/src/json_test.c
@@ -35,107 +35,107 @@ test_decode_find_end(void)
/* string and incomplete string */
reader.js_buf = (char_u *)"\"hello\"";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" \"hello\" ";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"\"hello";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
/* number and dash (incomplete number) */
reader.js_buf = (char_u *)"123";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"-";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
/* false, true and null, also incomplete */
reader.js_buf = (char_u *)"false";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"f";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"fa";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"fal";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"fals";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"true";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"t";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"tr";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"tru";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"null";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"n";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"nu";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"nul";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
/* object without white space */
reader.js_buf = (char_u *)"{\"a\":123}";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"{\"a\":123";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"{\"a\":";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"{\"a\"";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"{\"a";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"{\"";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"{";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
/* object with white space */
reader.js_buf = (char_u *)" { \"a\" : 123 } ";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" { \"a\" : 123 ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)" { \"a\" : ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)" { \"a\" ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)" { \"a ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)" { ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
/* array without white space */
reader.js_buf = (char_u *)"[\"a\",123]";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"[\"a\",123";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"[\"a\",";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"[\"a\"";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"[\"a";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"[\"";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)"[";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
/* array with white space */
reader.js_buf = (char_u *)" [ \"a\" , 123 ] ";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" [ \"a\" , 123 ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)" [ \"a\" , ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)" [ \"a\" ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)" [ \"a ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
reader.js_buf = (char_u *)" [ ";
- assert(json_find_end(&reader) == MAYBE);
+ assert(json_find_end(&reader, 0) == MAYBE);
}
static int
@@ -157,15 +157,15 @@ test_fill_called_on_find_end(void)
reader.js_used = 0;
reader.js_buf = (char_u *)" [ \"a\" , 123 ";
reader.js_cookie = " [ \"a\" , 123 ] ";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" [ \"a\" , ";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" [ \"a\" ";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" [ \"a";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" [ ";
- assert(json_find_end(&reader) == OK);
+ assert(json_find_end(&reader, 0) == OK);
}
/*