Skip to content

Commit

Permalink
eliuds-eggs: Add generators and regenerate tests (#811)
Browse files Browse the repository at this point in the history
* add generators and regenerate tests

* update function template
  • Loading branch information
tasxatzial authored Feb 19, 2025
1 parent 90692f5 commit fcf3c22
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
9 changes: 9 additions & 0 deletions exercises/practice/eliuds-eggs/.meta/generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(ns eliuds-eggs-test
(:require [clojure.test :refer [deftest testing is]]
eliuds-eggs))

{{#test_cases.eggCount}}
(deftest egg-count_test_{{idx}}
(testing {{description}}
(is (= {{expected}} (eliuds-eggs/egg-count {{input.number}})))))
{{/test_cases.eggCount}}
8 changes: 5 additions & 3 deletions exercises/practice/eliuds-eggs/src/eliuds_eggs.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns eliuds-eggs)

(defn egg-count [number]
;; your code goes here
)
(defn egg-count
"Returns the number of 1 bits in the binary representation of the given number."
[number]
;; function body
)
22 changes: 13 additions & 9 deletions exercises/practice/eliuds-eggs/test/eliuds_eggs_test.clj
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
(ns eliuds-eggs-test
(:require [clojure.test :refer [deftest is]]
(:require [clojure.test :refer [deftest testing is]]
eliuds-eggs))

(deftest no-eggs
(is (= 0 (eliuds-eggs/egg-count 0))))
(deftest egg-count_test_1
(testing "0 eggs"
(is (= 0 (eliuds-eggs/egg-count 0)))))

(deftest one-egg
(is (= 1 (eliuds-eggs/egg-count 16))))
(deftest egg-count_test_2
(testing "1 egg"
(is (= 1 (eliuds-eggs/egg-count 16)))))

(deftest four-eggs
(is (= 4 (eliuds-eggs/egg-count 89))))
(deftest egg-count_test_3
(testing "4 eggs"
(is (= 4 (eliuds-eggs/egg-count 89)))))

(deftest thirteen-eggs
(is (= 13 (eliuds-eggs/egg-count 2000000000))))
(deftest egg-count_test_4
(testing "13 eggs"
(is (= 13 (eliuds-eggs/egg-count 2000000000)))))

0 comments on commit fcf3c22

Please sign in to comment.