emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 3f63ae5: Add more Unicode test cases for JSON conve


From: Philipp Stephani
Subject: [Emacs-diffs] master 3f63ae5: Add more Unicode test cases for JSON conversion
Date: Sun, 24 Dec 2017 08:12:57 -0500 (EST)

branch: master
commit 3f63ae54ecc22de51930cba1b118e93f7decd45e
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>

    Add more Unicode test cases for JSON conversion
    
    * test/src/json-tests.el (json-parse-string/string)
    (json-serialize/string, json-serialize/invalid-unicode)
    (json-parse-string/invalid-unicode): Add more Unicode test cases.
---
 test/src/json-tests.el | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/test/src/json-tests.el b/test/src/json-tests.el
index b23439a..e394583 100644
--- a/test/src/json-tests.el
+++ b/test/src/json-tests.el
@@ -92,7 +92,9 @@
   (should (equal (json-parse-string "[\"\\nasd\\u0444\\u044b\\u0432fgh\\t\"]")
                  ["\nasdфывfgh\t"]))
   (should (equal (json-parse-string "[\"\\uD834\\uDD1E\"]") ["\U0001D11E"]))
-  (should-error (json-parse-string "foo") :type 'json-parse-error))
+  (should-error (json-parse-string "foo") :type 'json-parse-error)
+  ;; FIXME: Is this the right behavior?
+  (should (equal (json-parse-string "[\"\u00C4\xC3\x84\"]") ["\u00C4\u00C4"])))
 
 (ert-deftest json-serialize/string ()
   (skip-unless (fboundp 'json-serialize))
@@ -100,7 +102,9 @@
   (should (equal (json-serialize ["a\n\fb"]) "[\"a\\n\\fb\"]"))
   (should (equal (json-serialize ["\nasdфыв\u001f\u007ffgh\t"])
                  "[\"\\nasdфыв\\u001F\u007ffgh\\t\"]"))
-  (should (equal (json-serialize ["a\0b"]) "[\"a\\u0000b\"]")))
+  (should (equal (json-serialize ["a\0b"]) "[\"a\\u0000b\"]"))
+  ;; FIXME: Is this the right behavior?
+  (should (equal (json-serialize ["\u00C4\xC3\x84"]) "[\"\u00C4\u00C4\"]")))
 
 (ert-deftest json-serialize/invalid-unicode ()
   (skip-unless (fboundp 'json-serialize))
@@ -109,7 +113,8 @@
   (should-error (json-serialize ["a\uDBBBb"]) :type 'json-out-of-memory)
   (should-error (json-serialize ["u\x110000v"]) :type 'json-out-of-memory)
   (should-error (json-serialize ["u\x3FFFFFv"]) :type 'json-out-of-memory)
-  (should-error (json-serialize ["u\xCCv"]) :type 'json-out-of-memory))
+  (should-error (json-serialize ["u\xCCv"]) :type 'json-out-of-memory)
+  (should-error (json-serialize ["u\u00C4\xCCv"]) :type 'json-out-of-memory))
 
 (ert-deftest json-parse-string/null ()
   (skip-unless (fboundp 'json-parse-string))
@@ -119,22 +124,33 @@
 
 (ert-deftest json-parse-string/invalid-unicode ()
   "Some examples from
-https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt.";
+https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt.
+Test with both unibyte and multibyte strings."
   (skip-unless (fboundp 'json-parse-string))
   ;; Invalid UTF-8 code unit sequences.
   (should-error (json-parse-string "[\"\x80\"]") :type 'json-parse-error)
+  (should-error (json-parse-string "[\"\u00C4\x80\"]") :type 'json-parse-error)
   (should-error (json-parse-string "[\"\xBF\"]") :type 'json-parse-error)
+  (should-error (json-parse-string "[\"\u00C4\xBF\"]") :type 'json-parse-error)
   (should-error (json-parse-string "[\"\xFE\"]") :type 'json-parse-error)
+  (should-error (json-parse-string "[\"\u00C4\xFE\"]") :type 'json-parse-error)
   (should-error (json-parse-string "[\"\xC0\xAF\"]") :type 'json-parse-error)
-  (should-error (json-parse-string "[\"\xC0\x80\"]") :type 'json-parse-error)
+  (should-error (json-parse-string "[\"\u00C4\xC0\xAF\"]")
+                :type 'json-parse-error)
+  (should-error (json-parse-string "[\"\u00C4\xC0\x80\"]")
+                :type 'json-parse-error)
   ;; Surrogates.
   (should-error (json-parse-string "[\"\uDB7F\"]")
                 :type 'json-parse-error)
   (should-error (json-parse-string "[\"\xED\xAD\xBF\"]")
                 :type 'json-parse-error)
+  (should-error (json-parse-string "[\"\u00C4\xED\xAD\xBF\"]")
+                :type 'json-parse-error)
   (should-error (json-parse-string "[\"\uDB7F\uDFFF\"]")
                 :type 'json-parse-error)
   (should-error (json-parse-string "[\"\xED\xAD\xBF\xED\xBF\xBF\"]")
+                :type 'json-parse-error)
+  (should-error (json-parse-string "[\"\u00C4\xED\xAD\xBF\xED\xBF\xBF\"]")
                 :type 'json-parse-error))
 
 (ert-deftest json-parse-string/incomplete ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]