Skip to content
Snippets Groups Projects
Unverified Commit 180780c0 authored by Cam Saul's avatar Cam Saul Committed by GitHub
Browse files

Remove unused occurances-of-substring fn (#12979)

parent 1d0dafad
No related branches found
No related tags found
No related merge requests found
......@@ -554,15 +554,6 @@
"Increment `n` if it is non-`nil`, otherwise return `1` (e.g. as if incrementing `0`)."
(fnil inc 0))
(defn occurances-of-substring
"Return the number of times SUBSTR occurs in string S."
^Long [^String s, ^String substr]
(when (and (seq s) (seq substr))
(loop [index 0, cnt 0]
(if-let [^long new-index (str/index-of s substr index)]
(recur (inc new-index) (inc cnt))
cnt))))
(defn select-non-nil-keys
"Like `select-keys`, but returns a map only containing keys in KS that are present *and non-nil* in M.
......
......@@ -151,25 +151,6 @@
"<<>>" false
"{\"a\": 10}" false))
(deftest occurances-of-substring-test
(testing "should return nil if one or both strings are nil or empty"
(are+ [s substr expected] (= expected
(u/occurances-of-substring s substr))
nil nil nil
nil "" nil
"" nil nil
"" "" nil
"ABC" "" nil
"" " ABC" nil
;; non-empty strings
"ABC" "A" 1
"ABA" "A" 2
"AAA" "A" 3
"ABC" "{{id}}" 0
"WHERE ID = {{id}}" "{{id}}" 1
"WHERE ID = {{id}} OR USER_ID = {{id}}" "{{id}}" 2
"WHERE ID = {{id}} OR USER_ID = {{id}} OR TOUCAN_ID = {{id}} OR BIRD_ID = {{bird}}" "{{id}}" 3)))
(deftest select-keys-test
(testing "select-non-nil-keys"
(is (= {:a 100}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment