Permalink
Browse files

added tests for EOF in unterminated strings and arrays

Signed-off-by: Stuart Sierra <mail@stuartsierra.com>
  • Loading branch information...
1 parent 63c047e commit c81595e1f47a13aa2faab4934edfeef4d60a21f4 @ska2342 ska2342 committed with stuartsierra Dec 14, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/test/clojure/clojure/data/json_test.clj
@@ -237,6 +237,14 @@
(deftest default-throws-on-eof
(is (thrown? java.io.EOFException (json/read-str ""))))
+(deftest throws-eof-in-unterminated-array
+ (is (thrown-with-msg? java.io.EOFException #"end-of-file inside array"
+ (json/read-str "[1, "))))
+
+(deftest throws-eof-in-unterminated-string
+ (is (thrown-with-msg? java.io.EOFException #"end-of-file inside string"
+ (json/read-str "\"missing end quote"))))
+
(deftest accept-eof
(is (= ::eof (json/read-str "" :eof-error? false :eof-value ::eof))))

0 comments on commit c81595e

Please sign in to comment.