Public Vars

Back

char-array (clj)

(source)

function

(char-array size-or-seq) (char-array size init-val-or-seq)
Creates an array of chars

Examples

mikera/core.matrix
(ns clojure.core.matrix.test-arrays
  (:refer-clojure :exclude [vector?])
  (:require [clojure.core.matrix.compliance-tester :as compliance]
            [clojure.core.matrix :as m]
            ;[clojure.core.matrix.utils :refer :all]
            [clojure.test :refer [deftest testing is]]
            [clojure.core.matrix.macros :refer [array?]]))

(deftest compliance-tests
  (compliance/instance-test (int-array [1 2 3]))
  (compliance/instance-test (float-array [1 2 3]))
  (compliance/instance-test (long-array []))
  (compliance/instance-test (char-array [\a \b \c]))
  (compliance/instance-test (object-array [(double-array [1 2 3])]))
  (compliance/instance-test (object-array [(short-array (map short [1 2 3]))]))
  (compliance/instance-test (into-array (Class/forName "[D")
                                        [(double-array [1 2])
                                         (double-array [3 4])])))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

;array ctors
#?@(:cljs [] :default [
cc/boolean-array (t/IFn [(t/U t/Num (t/Seqable t/Bool)) :-> (Array boolean)]
                        [t/Num (t/U t/Bool (t/Seqable t/Bool)) :-> (Array boolean)])
cc/byte-array (t/IFn [(t/U t/Num (t/Seqable Byte)) :-> (Array byte)]
                     [t/Num (t/U Byte (t/Seqable Byte)) :-> (Array byte)])
cc/char-array (t/IFn [(t/U t/Num (t/Seqable Character)) :-> (Array char)]
                     [t/Num (t/U t/Num (t/Seqable Character)) :-> (Array char)])
cc/short-array (t/IFn [(t/U t/Num (t/Seqable Short)) :-> (Array short)]
                      [t/Num (t/U Short (t/Seqable Short)) :-> (Array short)])
cc/int-array (t/IFn [(t/U t/Num (t/Seqable t/Num)) :-> (Array int)]
                    [t/Num (t/U t/Num (t/Seqable t/Num)) :-> (Array int)])
cc/double-array (t/IFn [(t/U t/Num (t/Seqable t/Num)) :-> (Array double)]
                       [t/Num (t/U t/Num (t/Seqable t/Num)) :-> (Array double)])
])
replikativ/konserve
(ns konserve.filestore-test
  (:refer-clojure :exclude [get get-in update update-in assoc assoc-in dissoc exists? keys])
  (:require [clojure.test :refer [deftest is testing]]
            [clojure.core.async :refer [<!! go chan put! close! <!] :as async]
            [konserve.core :refer [bassoc bget keys]]
            [konserve.compliance-test :refer [compliance-test]]
            [konserve.filestore :refer [connect-fs-store delete-store]]
            [konserve.tests.cache :as ct]
            [konserve.tests.encryptor :as et]
            [konserve.tests.gc :as gct]
            [konserve.tests.serializers :as st]))

(deftest binary-polymorhism-test
  (testing "Test storage of different binary input formats."
    (let [folder "/tmp/konserve-fs-test"
          _      (spit "/tmp/foo" (range 1 10))
          _      (delete-store folder)
          store  (<!! (connect-fs-store folder))]
      (testing "Binary"
        (testing "ByteArray"
          (let [res-ch (chan)]
            (is (= true (<!! (bassoc store :byte-array (byte-array (range 10))))))
            (is (= true (<!! (bget store :byte-array
                                   (fn [{:keys [input-stream]}]
                                     (go
                                       (put! res-ch (mapv byte (slurp input-stream)))))))))
            (is (=  (mapv byte (byte-array (range 10))) (<!! res-ch)))
            (close! res-ch)))
        (testing "CharArray"
          (let [res-ch (chan)]
            (is (= true (<!! (bassoc store :char-array (char-array "foo")))))
            (is (= true (<!! (bget store :char-array
                                   (fn [{:keys [input-stream]}]
                                     (go
                                       (put! res-ch (slurp input-stream))))))))
            (is (=  "foo" (<!! res-ch)))))
        (testing "File Inputstream"
          (let [res-ch (chan)]
            (spit "/tmp/foo" (range 1 10))
            (is (= true (<!! (bassoc store :file-input-stream (java.io.FileInputStream. "/tmp/foo")))))
            (is (= true (<!! (bget store :file-input-stream
                                   (fn [{:keys [input-stream]}]
                                     (go
                                       (put! res-ch (slurp input-stream))))))))
            (is (=  (str (range 1 10)) (<!! res-ch)))))
        (testing "Byte Array Inputstream"
          (let [res-ch (chan)]
            (is (= true (<!! (bassoc store :input-stream (java.io.ByteArrayInputStream. (byte-array (range 10)))))))
            (is (= true (<!! (bget store :input-stream
                                   (fn [{:keys [input-stream]}]
                                     (go
                                       (put! res-ch (map byte (slurp input-stream)))))))))
            (is (=  (map byte (byte-array (range 10))) (<!! res-ch)))
            (close! res-ch)))
        (testing "String"
          (let [res-ch (chan)]
            (is (= true (<!! (bassoc store :string "foo bar"))))
            (is (= true (<!! (bget store :string
                                   (fn [{:keys [input-stream]}]
                                     (go
                                       (put! res-ch (slurp input-stream))))))))
            (is (= "foo bar" (<!! res-ch)))))
        (testing "Reader"
          (let [res-ch (chan)]
            (is (= true (<!! (bassoc store :reader (java.io.StringReader. "foo bar")))))
            (is (= true (<!! (bget store :reader
                                   (fn [{:keys [input-stream]}]
                                     (go
                                       (put! res-ch (slurp input-stream))))))))
            (is (=  "foo bar" (<!! res-ch))))))
      (delete-store folder)
      (let [store (<!! (connect-fs-store folder))]
        (is (= (<!! (keys store))
               #{}))))))
yanatan16/clj-kubernetes-api
(ns kubernetes.api.v1-test
  (:require [clojure.test :refer :all]
            [clojure.string :as str]
            [clojure.core.async :refer (<!!) :as async]
            [kubernetes.api.v1 :as v1]))

(def ctx (v1/make-context "http://localhost:8080"))
(def tns (->> (repeatedly 10 #(rand-int 26))
              (map #(nth (char-array "abcdefghijklmnopqrstuvwxyz") %))
              (str/join "")))
(def nsopt {:namespace tns})
(def pod {:kind "Pod"
          :metadata {:name "test" :labels {:test "yes"}}
          :spec {:containers [{:name "nginx"
                               :image "nginx"}]}})
pjstadig/utf8
;;;; Copyright © 2013 Paul Stadig. All rights reserved.
;;;;
;;;; This Source Code Form is subject to the terms of the Mozilla Public
;;;; License, v. 2.0. If a copy of the MPL was not distributed with this file,
;;;; You can obtain one at http://mozilla.org/MPL/2.0/.
;;;;
;;;; This Source Code Form is "Incompatible With Secondary Licenses", as defined
;;;; by the Mozilla Public License, v. 2.0.
(ns pjstadig.test.utf8
  (:require [clojure.core :as clj]
            [clojure.java.io :as io]
            [clojure.test :refer :all]
            [pjstadig.utf8 :refer :all]))

(deftest test-utf8-writer
  (is (= (utf8-str "foofooooffooo")
         (utf8-str (with-open [x (utf8-writer)]
                     (.write x "foo")
                     (.write x (char-array (seq "foo")))
                     (.write x (char-array (seq "foo")) 1 2)
                     (-> x
                         (.append \f)
                         (.append "foo")
                         (.append "foo" 1 2))
                     x)))))