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

raindrops: Implement tests from problem specifications #668

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 57 additions & 33 deletions exercises/practice/raindrops/test/raindrops_test.clj
Original file line number Diff line number Diff line change
@@ -1,51 +1,75 @@
(ns raindrops-test
(:require [clojure.test :refer [deftest is]]
(:require [clojure.test :refer [deftest is testing]]
raindrops))

(deftest one
(is (= "1" (raindrops/convert 1))))
(deftest sound-for-1
(testing "The sound for 1 is 1"
(is (= "1" (raindrops/convert 1)))))

(deftest three
(is (= "Pling" (raindrops/convert 3))))
(deftest sound-for-3
(testing "The sound for 3 is Pling"
(is (= "Pling" (raindrops/convert 3)))))

(deftest five
(is (= "Plang" (raindrops/convert 5))))
(deftest sound-for-5
(testing "The sound for 5 is Plang"
(is (= "Plang" (raindrops/convert 5)))))

(deftest seven
(is (= "Plong" (raindrops/convert 7))))
(deftest sound-for-7
(testing "The sound for 7 is Plong"
(is (= "Plong" (raindrops/convert 7)))))

(deftest six
(is (= "Pling" (raindrops/convert 6))))
(deftest sound-for-6
(testing "The sound for 6 is Pling as it has a factor 3"
(is (= "Pling" (raindrops/convert 6)))))

(deftest nine
(is (= "Pling" (raindrops/convert 9))))
(deftest sound-for-8
(testing "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base"
(is (= "8" (raindrops/convert 8)))))

(deftest ten
(is (= "Plang" (raindrops/convert 10))))
(deftest sound-for-9
(testing "The sound for 9 is Pling as it has a factor 3"
(is (= "Pling" (raindrops/convert 9)))))

(deftest fourteen
(is (= "Plong" (raindrops/convert 14))))
(deftest sound-for-10
(testing "The sound for 10 is Plang as it has a factor 5"
(is (= "Plang" (raindrops/convert 10)))))

(deftest fifteen
(is (= "PlingPlang" (raindrops/convert 15))))
(deftest sound-for-14
(testing "The sound for 14 is Plong as it has a factor of 7"
(is (= "Plong" (raindrops/convert 14)))))

(deftest twenty-one
(is (= "PlingPlong" (raindrops/convert 21))))
(deftest sound-for-15
(testing "The sound for 15 is PlingPlang as it has factors 3 and 5"
(is (= "PlingPlang" (raindrops/convert 15)))))

(deftest twenty-five
(is (= "Plang" (raindrops/convert 25))))
(deftest sound-for-21
(testing "The sound for 21 is PlingPlong as it has factors 3 and 7"
(is (= "PlingPlong" (raindrops/convert 21)))))

(deftest thirty-five
(is (= "PlangPlong" (raindrops/convert 35))))
(deftest sound-for-25
(testing "The sound for 25 is Plang as it has a factor 5"
(is (= "Plang" (raindrops/convert 25)))))

(deftest forty-nine
(is (= "Plong" (raindrops/convert 49))))
(deftest sound-for-27
(testing "The sound for 27 is Pling as it has a factor 3"
(is (= "Pling" (raindrops/convert 27)))))

(deftest fifty-two
(is (= "52" (raindrops/convert 52))))
(deftest sound-for-35
(testing "The sound for 35 is PlangPlong as it has factors 5 and 7"
(is (= "PlangPlong" (raindrops/convert 35)))))

(deftest one-hundred-five
(is (= "PlingPlangPlong" (raindrops/convert 105))))
(deftest sound-for-49
(testing "The sound for 49 is Plong as it has a factor 7"
(is (= "Plong" (raindrops/convert 49)))))

(deftest twelve-thousand-one-hundred-twenty-one
(is (= "12121" (raindrops/convert 12121))))
(deftest sound-for-52
(testing "The sound for 52 is 52"
(is (= "52" (raindrops/convert 52)))))

(deftest sound-for-105
(testing "The sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7"
(is (= "PlingPlangPlong" (raindrops/convert 105)))))

(deftest sound-for-3125
(testing "The sound for 3125 is Plang as it has a factor 5"
(is (= "Plang" (raindrops/convert 3125)))))
Loading