Created
September 26, 2010 03:35
-
-
Save Diullei/597570 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; FizzBuzz - Testes | |
| ; Diullei Gomes | |
| ; [email protected] | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| (ns FizzBuzz.core-test | |
| (:use [FizzBuzz.core] :reload-all) | |
| (:use [clojure.test])) | |
| (deftest quando-passo-1-deve-retornar-1 | |
| (is (= 1 (fizz-buzz? 1)))) | |
| (deftest quando-passo-2-deve-retornar-2 | |
| (is (= 2 (fizz-buzz? 2)))) | |
| (deftest quando-passo-3-deve-retornar-Fizz | |
| (is (= "Fizz" (fizz-buzz? 3)))) | |
| (deftest quando-passo-4-deve-retornar-4 | |
| (is (= 4 (fizz-buzz? 4)))) | |
| (deftest quando-passo-5-deve-retornar-Buzz | |
| (is (= "Buzz" (fizz-buzz? 5)))) | |
| (deftest quando-passo-6-deve-retornar-Fizz | |
| (is (= "Fizz" (fizz-buzz? 6)))) | |
| (deftest quando-passo-9-deve-retornar-Fizz | |
| (is (= "Fizz" (fizz-buzz? 9)))) | |
| (deftest quando-passo-10-deve-retornar-Buzz | |
| (is (= "Buzz" (fizz-buzz? 10)))) | |
| (deftest quando-passo-13-deve-retornar-Fizz | |
| (is (= "Fizz" (fizz-buzz? 13)))) | |
| (deftest quando-passo-30-deve-retornar-FizzBuzz | |
| (is (= "FizzBuzz" (fizz-buzz? 30)))) | |
| (deftest quando-passo-52-deve-retornar-Buzz | |
| (is (= "Buzz" (fizz-buzz? 52)))) | |
| (deftest quando-passo-58-deve-retornar-Buzz | |
| (is (= "Buzz" (fizz-buzz? 58)))) | |
| (deftest quando-passo-51-deve-retornar-Fizz | |
| (is (= "Fizz" (fizz-buzz? 51)))) | |
| (deftest quando-passo-53-deve-retornar-Fizz | |
| (is (= "Fizz" (fizz-buzz? 53)))) | |
| (deftest quando-passo-15-deve-retornar-FizzBuzz | |
| (is (= "FizzBuzz" (fizz-buzz? 15)))) | |
| (deftest quando-passo-a-lista-1-2-3-deve-retornar-uma-lista-1-2-Fizz | |
| (is (= '(1 2 "Fizz") (map fizz-buzz? '(1 2 3))))) | |
| (deftest quando-passo-a-lista-1-2-3-4-5-6-7-8-9-10-30-deve-retornar-uma-lista-1-2-Fizz-4-Buzz-Fizz-7-8-Fizz-Buzz-FizzBuzz | |
| (is | |
| (= '(1 2 "Fizz" 4 "Buzz" "Fizz" 7 8 "Fizz" "Buzz" "FizzBuzz") | |
| (map fizz-buzz? '(1 2 3 4 5 6 7 8 9 10 30))))) |
This file contains hidden or 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
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; FizzBuzz | |
| ; Diullei Gomes | |
| ; [email protected] | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| (ns FizzBuzz.core) | |
| (defn eh-uma-lista? [input] | |
| (= (list? input) true)) | |
| (defn nao-eh-uma-lista-vazia? [input] | |
| (not (empty? input))) | |
| (defn eh-divisivel-por-3? [input] | |
| (= (rem input 3) 0)) | |
| (defn eh-divisivel-por-5? [input] | |
| (= (rem input 5) 0)) | |
| (defn eh-divisivel-por-3-e-por-5? [input] | |
| (= (eh-divisivel-por-3? input) (eh-divisivel-por-5? input) true)) | |
| (defn contem-o-numero-3? [input] | |
| (.contains (.toString input) "3")) | |
| (defn contem-o-numero-5? [input] | |
| (.contains (.toString input) "5")) | |
| (defn fizz-buzz? | |
| [input] | |
| (cond | |
| (eh-divisivel-por-3-e-por-5? input) "FizzBuzz" | |
| (eh-divisivel-por-3? input) "Fizz" | |
| (eh-divisivel-por-5? input) "Buzz" | |
| (contem-o-numero-3? input) "Fizz" | |
| (contem-o-numero-5? input) "Buzz" | |
| :else input | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment