Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Jan 22, 2025
1 parent c98e101 commit 1b3e410
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/resistor-color-trio/.meta/example.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

(defn unit-label [[amount unit]] (str amount " " unit "ohms"))

(defn label [colors]
(defn resistor-label [colors]
(let [value (colors->value colors)]
(->> units
(map-indexed vector)
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/resistor-color-trio/.meta/generator.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
resistor-color-trio))

{{#test_cases.label}}
(deftest label_test_{{idx}}
(deftest resistor-label_test_{{idx}}
(testing {{description}}
(is (= {{expected}} (resistor-color-trio/label {{input.colors}})))))
(is (= {{expected}} (resistor-color-trio/resistor-label {{input.colors}})))))
{{/test_cases.label}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@
(:require [clojure.test :refer [deftest testing is]]
resistor-color-trio))

(deftest label_test_1
(deftest resistor-label_test_1
(testing "Orange and orange and black"
(is (= "33 ohms" (resistor-color-trio/label ["orange" "orange" "black"])))))
(is (= "33 ohms" (resistor-color-trio/resistor-label ["orange" "orange" "black"])))))

(deftest label_test_2
(deftest resistor-label_test_2
(testing "Blue and grey and brown"
(is (= "680 ohms" (resistor-color-trio/label ["blue" "grey" "brown"])))))
(is (= "680 ohms" (resistor-color-trio/resistor-label ["blue" "grey" "brown"])))))

(deftest label_test_3
(deftest resistor-label_test_3
(testing "Red and black and red"
(is (= "2 kiloohms" (resistor-color-trio/label ["red" "black" "red"])))))
(is (= "2 kiloohms" (resistor-color-trio/resistor-label ["red" "black" "red"])))))

(deftest label_test_4
(deftest resistor-label_test_4
(testing "Green and brown and orange"
(is (= "51 kiloohms" (resistor-color-trio/label ["green" "brown" "orange"])))))
(is (= "51 kiloohms" (resistor-color-trio/resistor-label ["green" "brown" "orange"])))))

(deftest label_test_5
(deftest resistor-label_test_5
(testing "Yellow and violet and yellow"
(is (= "470 kiloohms" (resistor-color-trio/label ["yellow" "violet" "yellow"])))))
(is (= "470 kiloohms" (resistor-color-trio/resistor-label ["yellow" "violet" "yellow"])))))

(deftest label_test_6
(deftest resistor-label_test_6
(testing "Blue and violet and blue"
(is (= "67 megaohms" (resistor-color-trio/label ["blue" "violet" "blue"])))))
(is (= "67 megaohms" (resistor-color-trio/resistor-label ["blue" "violet" "blue"])))))

(deftest label_test_7
(deftest resistor-label_test_7
(testing "Minimum possible value"
(is (= "0 ohms" (resistor-color-trio/label ["black" "black" "black"])))))
(is (= "0 ohms" (resistor-color-trio/resistor-label ["black" "black" "black"])))))

(deftest label_test_8
(deftest resistor-label_test_8
(testing "Maximum possible value"
(is (= "99 gigaohms" (resistor-color-trio/label ["white" "white" "white"])))))
(is (= "99 gigaohms" (resistor-color-trio/resistor-label ["white" "white" "white"])))))

(deftest label_test_9
(deftest resistor-label_test_9
(testing "First two colors make an invalid octal number"
(is (= "8 ohms" (resistor-color-trio/label ["black" "grey" "black"])))))
(is (= "8 ohms" (resistor-color-trio/resistor-label ["black" "grey" "black"])))))

(deftest label_test_10
(deftest resistor-label_test_10
(testing "Ignore extra colors"
(is (= "650 kiloohms" (resistor-color-trio/label ["blue" "green" "yellow" "orange"])))))
(is (= "650 kiloohms" (resistor-color-trio/resistor-label ["blue" "green" "yellow" "orange"])))))

0 comments on commit 1b3e410

Please sign in to comment.