aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorPhilipp Stephani2017-09-18 18:00:45 +0200
committerPhilipp Stephani2017-09-18 18:00:45 +0200
commit0925a20e0a48bc5ff8e9bad6ca4aa0a4c91fdc3c (patch)
tree504d5533ad5177b4156dcc691cffc62ba510ee3e /test/src
parentcb99cf5a99680af7dc2c49fdf5b840d1ff4dd928 (diff)
downloademacs-0925a20e0a48bc5ff8e9bad6ca4aa0a4c91fdc3c.tar.gz
emacs-0925a20e0a48bc5ff8e9bad6ca4aa0a4c91fdc3c.zip
Revert "Implement native JSON support using Jansson"
This reverts commit cb99cf5a99680af7dc2c49fdf5b840d1ff4dd928.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/json-tests.el61
1 files changed, 0 insertions, 61 deletions
diff --git a/test/src/json-tests.el b/test/src/json-tests.el
deleted file mode 100644
index 1d8f9a490ba..00000000000
--- a/test/src/json-tests.el
+++ /dev/null
@@ -1,61 +0,0 @@
1;;; json-tests.el --- unit tests for json.c -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2017 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;; Unit tests for src/json.c.
23
24;;; Code:
25
26(require 'cl-lib)
27(require 'map)
28
29(ert-deftest json-serialize/roundtrip ()
30 (let ((lisp [nil :json-false t 0 123 -456 3.75 "foo"])
31 (json "[null,false,true,0,123,-456,3.75,\"foo\"]"))
32 (should (equal (json-serialize lisp) json))
33 (with-temp-buffer
34 (json-insert lisp)
35 (should (equal (buffer-string) json))
36 (should (eobp)))
37 (should (equal (json-parse-string json) lisp))
38 (with-temp-buffer
39 (insert json)
40 (goto-char 1)
41 (should (equal (json-parse-buffer) lisp))
42 (should (eobp)))))
43
44(ert-deftest json-serialize/object ()
45 (let ((table (make-hash-table :test #'equal)))
46 (puthash "abc" [1 2 t] table)
47 (puthash "def" nil table)
48 (should (equal (json-serialize table)
49 "{\"abc\":[1,2,true],\"def\":null}"))))
50
51(ert-deftest json-parse-string/object ()
52 (let ((actual
53 (json-parse-string
54 "{ \"abc\" : [1, 2, true], \"def\" : null, \"abc\" : [9, false] }\n")))
55 (should (hash-table-p actual))
56 (should (equal (hash-table-count actual) 2))
57 (should (equal (cl-sort (map-pairs actual) #'string< :key #'car)
58 '(("abc" . [9 :json-false]) ("def"))))))
59
60(provide 'json-tests)
61;;; json-tests.el ends here