aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/json-tests.el
diff options
context:
space:
mode:
authorEli Zaretskii2018-10-13 10:13:10 +0300
committerEli Zaretskii2018-10-13 10:13:10 +0300
commit95f69e7db235ca450a17c5a24680b742dfdf9aae (patch)
treec186902d218c8fca88d3379f84f26738cdfc9fc5 /test/src/json-tests.el
parent6cf4dfe472650b3396d2f2592726621a43896de3 (diff)
downloademacs-95f69e7db235ca450a17c5a24680b742dfdf9aae.tar.gz
emacs-95f69e7db235ca450a17c5a24680b742dfdf9aae.zip
Improve 'json-insert' so it doesn't cons a string from JSON
* src/json.c (struct json_buffer_and_size): New member inserted_bytes. (json_insert): Instead of creating a string and inserting it into the current buffer, copy the unibyte text into the gap. (struct json_insert_data): New member inserted_bytes. (json_insert_callback): Update commentary. Pass the inserted_bytes value to json_insert and on its return copy the updated value back into DATA. (Fjson_insert): Decode the unibyte text inserted into the gap. Call before-change-functions and after-change-functions only once, before and after processing the insertion of the entire JSON representation. * test/src/json-tests.el (json-insert/throw): Adapt to the modified implementation of json-insert: it no longer calls the modification hooks once for each inserted chunk of JSON representation.
Diffstat (limited to 'test/src/json-tests.el')
-rw-r--r--test/src/json-tests.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/src/json-tests.el b/test/src/json-tests.el
index 911bc49730d..bffee8f39d3 100644
--- a/test/src/json-tests.el
+++ b/test/src/json-tests.el
@@ -272,10 +272,11 @@ Test with both unibyte and multibyte strings."
272 (cl-incf calls) 272 (cl-incf calls)
273 (throw 'test-tag 'throw-value)) 273 (throw 'test-tag 'throw-value))
274 :local) 274 :local)
275 (should-error 275 (should
276 (catch 'test-tag 276 (equal
277 (json-insert '((a . "b") (c . 123) (d . [1 2 t :false])))) 277 (catch 'test-tag
278 :type 'no-catch) 278 (json-insert '((a . "b") (c . 123) (d . [1 2 t :false]))))
279 'throw-value))
279 (should (equal calls 1))))) 280 (should (equal calls 1)))))
280 281
281(ert-deftest json-serialize/bignum () 282(ert-deftest json-serialize/bignum ()