Skip to content

Commit 4255382

Browse files
authored
Merge pull request #31 from joelittlejohn/unicode-decode
Add failing test for Unicode decoding
2 parents 29f50f7 + 05ac5d1 commit 4255382

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/byte_streams_test.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
[java.nio.charset
1111
Charset]
1212
[java.io
13+
ByteArrayInputStream
1314
File]
1415
[java.nio
1516
ByteBuffer]
@@ -129,3 +130,14 @@
129130
to-input-stream
130131
(convert (seq-of ByteBuffer) {:chunk-size 1})
131132
to-byte-array)))))
133+
134+
(deftest test-unicode-decoding
135+
(let [three-byte-char ""
136+
text (apply str (repeat 10000 three-byte-char))
137+
text-bytes (.getBytes text "utf-8")]
138+
(is (bytes= text-bytes
139+
(.getBytes (convert text-bytes String) "utf-8")))
140+
(is (bytes= text-bytes
141+
(.getBytes (convert (ByteArrayInputStream. text-bytes) String) "utf-8")))
142+
(is (bytes= text-bytes
143+
(.getBytes (convert (ByteArrayInputStream. text-bytes) String {:chunk-size 100}) "utf-8")))))

0 commit comments

Comments
 (0)