Back

split (clj)

(source)

protocol

(split this s)
: StringSeparator -> String -> NonEmptySeq[String]

Examples

camel-snake-kebab
(ns camel-snake-kebab.internals.string-separator-test
  (:require [camel-snake-kebab.internals.string-separator :refer [split generic-separator]]
            #?(:clj [clojure.test :refer :all]
               :cljs [cljs.test :refer-macros [deftest testing is are]])))

(deftest split-test
  (testing "regex, string and character separators"
    (are [sep]
      (and (= ["foo" "bar"] (split sep "foo.bar"))
           (= [""]          (split sep "")))
      #"\." "." \.))

  (testing "input consisting of separator(s)"
    (is (empty? (split "x" "x")))
    (is (empty? (split "x" "xx"))))

  (testing "generic separator"
    (are [x y]
      (= x (split generic-separator y))