Skip to content

Commit

Permalink
Add inital test function
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
shenanigansd authored Jan 15, 2025
1 parent 7b90188 commit 06d26b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/letsbuilda/imsosorrybutinparentheses.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns letsbuilda.imsosorrybutinparentheses)

(defn foo
"I don't do a whole lot."
[x]
(prn x "Hello, World!"))
(def regex-word-replace (re-pattern "(?<!w)[lr](?!w)"))

(defn char-replace [text]
(clojure.string/replace text regex-word-replace "w"))
13 changes: 10 additions & 3 deletions test/letsbuilda/imsosorrybutinparentheses_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
(:require [clojure.test :refer :all]
[letsbuilda.imsosorrybutinparentheses :refer :all]))

(deftest a-test
(testing "FIXME, I fail."
(is (= 0 1))))
(deftest char-replace-test
(testing "Replacing 'l' and 'r' with 'w' when not surrounded by 'w'"
(is (= "hewwo wowwd" (char-replace "hello world"))) ;; basic case
(is (= "woww" (char-replace "roll"))) ;; both 'r' and 'l' replaced
(is (= "wawe" (char-replace "rare"))) ;; 'r' in the middle replaced
(is (= "wlwlwl" (char-replace "wlwlwl"))) ;; no replacements where 'w' is involved
(is (= "w" (char-replace "l"))) ;; single character replaced
(is (= "w" (char-replace "r"))) ;; single character replaced
(is (= "" (char-replace ""))) ;; edge case: empty string
))

0 comments on commit 06d26b3

Please sign in to comment.