-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reverse-string: Add generator and regenerate tests (#774)
* add generator and regenerate tests * update example solution * update starter file * update contributors * fix example solution
- Loading branch information
1 parent
3f9f0f5
commit 57805fa
Showing
6 changed files
with
62 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ | |
"amscotti", | ||
"AndreaCrotti", | ||
"haus", | ||
"mtkp" | ||
"mtkp", | ||
"tasxatzial" | ||
], | ||
"files": { | ||
"solution": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(ns reverse-string | ||
(:require [clojure.string :as s])) | ||
(ns reverse-string) | ||
|
||
(defn reverse-string | ||
([word] (s/reverse word))) | ||
[s] | ||
(apply str (into () s))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(ns reverse-string-test | ||
(:require [clojure.test :refer [deftest testing is]] | ||
reverse-string)) | ||
{{#test_cases.reverse}} | ||
(deftest reverse-string_test_{{idx}} | ||
(testing {{description}} | ||
(is (= {{expected}} (reverse-string/reverse-string {{input.value}}))))) | ||
{{/test_cases.reverse~}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
(ns reverse-string) | ||
|
||
(defn reverse-string [s] ;; <- arglist goes here | ||
;; your code goes here | ||
) | ||
(defn reverse-string | ||
"Reverses the given string" | ||
[s] | ||
;; function body | ||
) |
42 changes: 23 additions & 19 deletions
42
exercises/practice/reverse-string/test/reverse_string_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
(ns reverse-string-test | ||
(:require [clojure.test :refer [deftest testing is]] | ||
[reverse-string :refer [reverse-string]])) | ||
reverse-string)) | ||
|
||
(deftest empty-string | ||
(testing "An empty string" | ||
(is (= "" (reverse-string ""))))) | ||
(deftest reverse-string_test_1 | ||
(testing "an empty string" | ||
(is (= "" (reverse-string/reverse-string ""))))) | ||
|
||
(deftest a-word | ||
(testing "A word" | ||
(is (= "tobor" (reverse-string "robot"))))) | ||
(deftest reverse-string_test_2 | ||
(testing "a word" | ||
(is (= "tobor" (reverse-string/reverse-string "robot"))))) | ||
|
||
(deftest capitalised-word | ||
(testing "A capitalized word" | ||
(is (= "nemaR" (reverse-string "Ramen"))))) | ||
(deftest reverse-string_test_3 | ||
(testing "a capitalized word" | ||
(is (= "nemaR" (reverse-string/reverse-string "Ramen"))))) | ||
|
||
(deftest sentence-with-punctuation | ||
(testing "A sentence with punctuation" | ||
(is (= "!yrgnuh m'I" (reverse-string "I'm hungry!"))))) | ||
(deftest reverse-string_test_4 | ||
(testing "a sentence with punctuation" | ||
(is (= "!yrgnuh m'I" (reverse-string/reverse-string "I'm hungry!"))))) | ||
|
||
(deftest palindrome | ||
(testing "A palindrome" | ||
(is (= "racecar" (reverse-string "racecar"))))) | ||
(deftest reverse-string_test_5 | ||
(testing "a palindrome" | ||
(is (= "racecar" (reverse-string/reverse-string "racecar"))))) | ||
|
||
(deftest even-sized-word | ||
(testing "An even sized word" | ||
(is (= "reward" (reverse-string "drawer"))))) | ||
(deftest reverse-string_test_6 | ||
(testing "an even-sized word" | ||
(is (= "reward" (reverse-string/reverse-string "drawer"))))) | ||
|
||
(deftest reverse-string_test_7 | ||
(testing "wide characters" | ||
(is (= "猫子" (reverse-string/reverse-string "子猫"))))) |