Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converted shorten string #229

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 0 additions & 9 deletions source/shorten_string.yml

This file was deleted.

26 changes: 26 additions & 0 deletions src/battle_asserts/issues/shorten_string.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(ns battle-asserts.issues.shorten-string
(:require [clojure.test.check.generators :as gen]
[faker.generate :as faker]))

(def level :elementary)

(def description "Provide the word in the form of an acronym composed of the first letter,
the number of letters in the word minus 2 and the last letter of the word.")

(defn arguments-generator []
(let [words (repeatedly 50 faker/word)]
(gen/tuple (gen/such-that #(> (count %) 2) (gen/elements words)))))

(def test-data
[{:expected "L10n"
:arguments ["Localization"]}
{:expected "M17n"
:arguments ["Multilingualization"]}
{:expected "I18n"
:arguments ["Internationalization"]}])

(defn solution [s]
(str (first s)
(- (count s)
2)
(last s)))
14 changes: 14 additions & 0 deletions test/battle_asserts/issues/shorten_string_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(ns battle-asserts.issues.shorten-string-test
(:require [clojure.test :refer :all]
[clojure.test.check.properties :as prop :include-macros true]
[clojure.test.check.clojure-test :as ct :include-macros true]
[test-helper :as h]
[battle-asserts.issues.shorten-string :as issue]))

(ct/defspec spec-solution
20
(prop/for-all [v (issue/arguments-generator)]
(instance? String (apply issue/solution v))))

(deftest test-solution
(h/generate-tests issue/test-data issue/solution))
15 changes: 0 additions & 15 deletions test/issues/shorten_string_test.clj.bak

This file was deleted.