diff options
| author | Dmitry Gutov | 2015-03-23 00:52:07 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2015-03-23 00:52:07 +0200 |
| commit | 127377c7113d1f01bafbb09b6d6730e9d8e5ac2e (patch) | |
| tree | 260f62cbc17006942c04fc7dea0d44cecddd16fb | |
| parent | a3b6c249e9757761404c1f7a57de4217dcc2e583 (diff) | |
| download | emacs-127377c7113d1f01bafbb09b6d6730e9d8e5ac2e.tar.gz emacs-127377c7113d1f01bafbb09b6d6730e9d8e5ac2e.zip | |
Add a few tests for jsone.el
* test/automated/json-tests.el: New file.
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/automated/json-tests.el | 46 |
2 files changed, 50 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 15408a3c970..b12e9c044f5 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2015-03-22 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * automated/json-tests.el: New file. | ||
| 4 | |||
| 1 | 2015-03-19 Stefan Monnier <monnier@iro.umontreal.ca> | 5 | 2015-03-19 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 6 | ||
| 3 | * automated/eieio-tests.el (eieio-test-17-virtual-slot): Don't use | 7 | * automated/eieio-tests.el (eieio-test-17-virtual-slot): Don't use |
diff --git a/test/automated/json-tests.el b/test/automated/json-tests.el new file mode 100644 index 00000000000..378472e19e5 --- /dev/null +++ b/test/automated/json-tests.el | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | ;;; json-tests.el --- Test suite for json.el | ||
| 2 | |||
| 3 | ;; Copyright (C) 2015 Dmitry Gutov | ||
| 4 | |||
| 5 | ;; Author: Dmitry Gutov <dgutov@yandex.ru> | ||
| 6 | |||
| 7 | ;; This program 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 | ;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | (require 'json) | ||
| 24 | |||
| 25 | (ert-deftest json-encode-simple-alist () | ||
| 26 | (should (equal (json-encode '((a . 1) | ||
| 27 | (b . 2))) | ||
| 28 | "{\"a\":1,\"b\":2}"))) | ||
| 29 | |||
| 30 | (ert-deftest json-read-simple-alist () | ||
| 31 | (should (equal (json-read-from-string "{\"a\": 1, \"b\": 2}") | ||
| 32 | '((b . 2) | ||
| 33 | (a . 1))))) | ||
| 34 | |||
| 35 | (ert-deftest json-encode-string-with-special-chars () | ||
| 36 | (should (equal (json-encode-string "a\n\fb") | ||
| 37 | "\"a\\n\\fb\"")) | ||
| 38 | (should (equal (json-encode-string "\nasdфывfgh\t") | ||
| 39 | "\"\\nasd\\u0444\\u044b\\u0432fgh\\t\""))) | ||
| 40 | |||
| 41 | (ert-deftest json-read-string-with-special-chars () | ||
| 42 | (should (equal (json-read-from-string "\"\\nasd\\u0444\\u044b\\u0432fgh\\t\"") | ||
| 43 | "\nasdфывfgh\t"))) | ||
| 44 | |||
| 45 | (provide 'json-tests) | ||
| 46 | ;;; json-tests.el ends here | ||