diff options
author | Eli Zaretskii <eliz@gnu.org> | 2018-10-13 10:13:10 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2018-10-13 10:13:10 +0300 |
commit | 95f69e7db235ca450a17c5a24680b742dfdf9aae (patch) | |
tree | c186902d218c8fca88d3379f84f26738cdfc9fc5 /test/src/json-tests.el | |
parent | 6cf4dfe472650b3396d2f2592726621a43896de3 (diff) | |
download | emacs-95f69e7db235ca450a17c5a24680b742dfdf9aae.tar.gz |
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.el | 9 |
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." (cl-incf calls) (throw 'test-tag 'throw-value)) :local) - (should-error - (catch 'test-tag - (json-insert '((a . "b") (c . 123) (d . [1 2 t :false])))) - :type 'no-catch) + (should + (equal + (catch 'test-tag + (json-insert '((a . "b") (c . 123) (d . [1 2 t :false])))) + 'throw-value)) (should (equal calls 1))))) (ert-deftest json-serialize/bignum () |