Skip to content

Commit 40b3fc4

Browse files
cnautzeDerGuteMoritz
authored andcommitted
add test buf->array conversion
1 parent 84eec10 commit 40b3fc4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/aleph/netty_test.clj

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(:require
33
[aleph.netty :as netty]
44
[aleph.resource-leak-detector]
5-
[clojure.test :refer [deftest is]]
5+
[clojure.test :refer [deftest is testing]]
66
[manifold.stream :as s])
77
(:import
88
(io.netty.channel Channel ChannelConfig)
@@ -54,4 +54,15 @@
5454
(netty/put! channel s 6)
5555
(is (not (-> config .isAutoRead)))))
5656

57+
(deftest sliced-bytebuf-conversion
58+
(let [s "foObar"
59+
bbuf (netty/to-byte-buf s)
60+
sbuf (.slice bbuf 2 3)
61+
bary (netty/buf->array bbuf)
62+
sary (netty/buf->array sbuf)]
63+
(testing "Vanilla ByteBuf conversion"
64+
(is (= s (String. ^bytes bary))))
65+
(testing "Sliced ByteBuf conversion"
66+
(is (= (subs s 2 5) (String. ^bytes sary))))))
67+
5768
(aleph.resource-leak-detector/instrument-tests!)

0 commit comments

Comments
 (0)