                      (buf/allocate (buf/size spec) {:type :heap :impl :netty})
                      (buf/allocate (buf/size spec) {:type :direct :impl :netty})]]
         (doseq [buffer buffers]
-          ;; (println buffer spec)
           (let [written (buf/write! buffer data spec)]
             (t/is (= written (buf/size spec)))
             (let [[readed data'] (buf/read* buffer spec)]


#+cljs
(t/deftest spec-data-types
  (let [data [;; (buf/string 5) "12345"
              (buf/short)    100
              (buf/integer)  1001
              (buf/bool)     false
              (buf/double)   (double 4.3)
              (buf/float)    (float 3.5)
              (buf/byte)     (byte 32)]]
              ;; (buf/bytes 5)  (bytes/random-bytes 5)]]
    (doseq [[spec data] (partition 2 data)]
      (let [buffers [(buf/allocate (buf/size spec) {:impl :es6})]]
        (doseq [buffer buffers]

  (:require #+clj [clojure.test :as t]
            #+cljs [cljs.test :as t]
            [bytebuf.core :as buf]
            [bytebuf.buffer :as impl])
  #+clj
  (:import java.nio.ByteBuffer
           io.netty.buffer.ByteBuf))


#+clj
(defn random-bytes
  [^long numbytes]
  (let [sr (java.util.Random.)
        buffer (byte-array numbytes)]
    (.nextBytes sr buffer)
    buffer))

#+cljs
(defn random-bytes
  [^long numbytes]
  (let [buffer (js/Int8Array. numbytes)]
    (doseq [i (range numbytes)]
      (aset buffer i (rand-int 10)))
    buffer))

#+clj
(defn equals?
  "Check if two byte arrays are equals."
  [^bytes a ^bytes b]
  (java.util.Arrays/equals a b))

#+cljs
(defn equals?
  [^bytes a ^bytes b]
  (if (not= (.-length a) (.-length b))
    false
    (reduce (fn [acc i]
              (if (not= (aget a i) (aget b i))
                (reduced false)
                true))
            true
            (range (.-length a)))))

#+clj
(t/deftest allocate-heap-nio-buffer
