diff options
| author | Philipp Stephani | 2017-12-10 18:03:04 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2017-12-10 18:04:29 +0100 |
| commit | 07bcc2a243693a774fec9a2706eeb75cab619d33 (patch) | |
| tree | ab29e04d1587ea560056185f5da633611959a904 /test/src | |
| parent | 2b8a1b76920dbdfc39dab2ec29ab7650bf779275 (diff) | |
| download | emacs-07bcc2a243693a774fec9a2706eeb75cab619d33.tar.gz emacs-07bcc2a243693a774fec9a2706eeb75cab619d33.zip | |
Skip tests for json.c unless compiled with native JSON support.
* test/src/json-tests.el (json-serialize/roundtrip)
(json-serialize/object, json-parse-string/object)
(json-parse-string/string, json-serialize/string)
(json-parse-string/incomplete, json-parse-string/trailing)
(json-parse-buffer/incomplete, json-parse-buffer/trailing): Skip if
JSON functions aren't available.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/json-tests.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/src/json-tests.el b/test/src/json-tests.el index 5d3c84a136c..07eb41d0930 100644 --- a/test/src/json-tests.el +++ b/test/src/json-tests.el | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | (require 'map) | 27 | (require 'map) |
| 28 | 28 | ||
| 29 | (ert-deftest json-serialize/roundtrip () | 29 | (ert-deftest json-serialize/roundtrip () |
| 30 | (skip-unless (fboundp 'json-serialize)) | ||
| 30 | (let ((lisp [:null :false t 0 123 -456 3.75 "abcαβγ"]) | 31 | (let ((lisp [:null :false t 0 123 -456 3.75 "abcαβγ"]) |
| 31 | (json "[null,false,true,0,123,-456,3.75,\"abcαβγ\"]")) | 32 | (json "[null,false,true,0,123,-456,3.75,\"abcαβγ\"]")) |
| 32 | (should (equal (json-serialize lisp) json)) | 33 | (should (equal (json-serialize lisp) json)) |
| @@ -42,6 +43,7 @@ | |||
| 42 | (should (eobp))))) | 43 | (should (eobp))))) |
| 43 | 44 | ||
| 44 | (ert-deftest json-serialize/object () | 45 | (ert-deftest json-serialize/object () |
| 46 | (skip-unless (fboundp 'json-serialize)) | ||
| 45 | (let ((table (make-hash-table :test #'equal))) | 47 | (let ((table (make-hash-table :test #'equal))) |
| 46 | (puthash "abc" [1 2 t] table) | 48 | (puthash "abc" [1 2 t] table) |
| 47 | (puthash "def" :null table) | 49 | (puthash "def" :null table) |
| @@ -49,6 +51,7 @@ | |||
| 49 | "{\"abc\":[1,2,true],\"def\":null}")))) | 51 | "{\"abc\":[1,2,true],\"def\":null}")))) |
| 50 | 52 | ||
| 51 | (ert-deftest json-parse-string/object () | 53 | (ert-deftest json-parse-string/object () |
| 54 | (skip-unless (fboundp 'json-parse-string)) | ||
| 52 | (let ((actual | 55 | (let ((actual |
| 53 | (json-parse-string | 56 | (json-parse-string |
| 54 | "{ \"abc\" : [1, 2, true], \"def\" : null, \"abc\" : [9, false] }\n"))) | 57 | "{ \"abc\" : [1, 2, true], \"def\" : null, \"abc\" : [9, false] }\n"))) |
| @@ -58,6 +61,7 @@ | |||
| 58 | '(("abc" . [9 :false]) ("def" . :null)))))) | 61 | '(("abc" . [9 :false]) ("def" . :null)))))) |
| 59 | 62 | ||
| 60 | (ert-deftest json-parse-string/string () | 63 | (ert-deftest json-parse-string/string () |
| 64 | (skip-unless (fboundp 'json-parse-string)) | ||
| 61 | (should-error (json-parse-string "[\"formfeed\f\"]") :type 'json-parse-error) | 65 | (should-error (json-parse-string "[\"formfeed\f\"]") :type 'json-parse-error) |
| 62 | (should (equal (json-parse-string "[\"foo \\\"bar\\\"\"]") ["foo \"bar\""])) | 66 | (should (equal (json-parse-string "[\"foo \\\"bar\\\"\"]") ["foo \"bar\""])) |
| 63 | (should (equal (json-parse-string "[\"abcαβγ\"]") ["abcαβγ"])) | 67 | (should (equal (json-parse-string "[\"abcαβγ\"]") ["abcαβγ"])) |
| @@ -67,18 +71,22 @@ | |||
| 67 | (should-error (json-parse-string "foo") :type 'json-parse-error)) | 71 | (should-error (json-parse-string "foo") :type 'json-parse-error)) |
| 68 | 72 | ||
| 69 | (ert-deftest json-serialize/string () | 73 | (ert-deftest json-serialize/string () |
| 74 | (skip-unless (fboundp 'json-serialize)) | ||
| 70 | (should (equal (json-serialize ["foo"]) "[\"foo\"]")) | 75 | (should (equal (json-serialize ["foo"]) "[\"foo\"]")) |
| 71 | (should (equal (json-serialize ["a\n\fb"]) "[\"a\\n\\fb\"]")) | 76 | (should (equal (json-serialize ["a\n\fb"]) "[\"a\\n\\fb\"]")) |
| 72 | (should (equal (json-serialize ["\nasdфыв\u001f\u007ffgh\t"]) | 77 | (should (equal (json-serialize ["\nasdфыв\u001f\u007ffgh\t"]) |
| 73 | "[\"\\nasdфыв\\u001F\u007ffgh\\t\"]"))) | 78 | "[\"\\nasdфыв\\u001F\u007ffgh\\t\"]"))) |
| 74 | 79 | ||
| 75 | (ert-deftest json-parse-string/incomplete () | 80 | (ert-deftest json-parse-string/incomplete () |
| 81 | (skip-unless (fboundp 'json-parse-string)) | ||
| 76 | (should-error (json-parse-string "[123") :type 'json-end-of-file)) | 82 | (should-error (json-parse-string "[123") :type 'json-end-of-file)) |
| 77 | 83 | ||
| 78 | (ert-deftest json-parse-string/trailing () | 84 | (ert-deftest json-parse-string/trailing () |
| 85 | (skip-unless (fboundp 'json-parse-string)) | ||
| 79 | (should-error (json-parse-string "[123] [456]") :type 'json-trailing-content)) | 86 | (should-error (json-parse-string "[123] [456]") :type 'json-trailing-content)) |
| 80 | 87 | ||
| 81 | (ert-deftest json-parse-buffer/incomplete () | 88 | (ert-deftest json-parse-buffer/incomplete () |
| 89 | (skip-unless (fboundp 'json-parse-buffer)) | ||
| 82 | (with-temp-buffer | 90 | (with-temp-buffer |
| 83 | (insert "[123") | 91 | (insert "[123") |
| 84 | (goto-char 1) | 92 | (goto-char 1) |
| @@ -86,6 +94,7 @@ | |||
| 86 | (should (bobp)))) | 94 | (should (bobp)))) |
| 87 | 95 | ||
| 88 | (ert-deftest json-parse-buffer/trailing () | 96 | (ert-deftest json-parse-buffer/trailing () |
| 97 | (skip-unless (fboundp 'json-parse-buffer)) | ||
| 89 | (with-temp-buffer | 98 | (with-temp-buffer |
| 90 | (insert "[123] [456]") | 99 | (insert "[123] [456]") |
| 91 | (goto-char 1) | 100 | (goto-char 1) |