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

roman-numerals: add generator and regenerate tests #734

Merged
merged 1 commit into from
Jan 13, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions exercises/practice/roman-numerals/.meta/generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns roman-numerals-test
(:require [clojure.test :refer [deftest testing is]]
roman-numerals))
{{#test_cases.roman}}
(deftest numerals_test_{{idx}}
(testing "{{description}}"
(is (= "{{expected}}" (roman-numerals/numerals {{input.number}})))))
{{/test_cases.roman~}}
75 changes: 53 additions & 22 deletions exercises/practice/roman-numerals/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,60 +1,91 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[19828a3a-fbf7-4661-8ddd-cbaeee0e2178]
description = "1 is a single I"
description = "1 is I"

[f088f064-2d35-4476-9a41-f576da3f7b03]
description = "2 is two I's"
description = "2 is II"

[b374a79c-3bea-43e6-8db8-1286f79c7106]
description = "3 is three I's"
description = "3 is III"

[05a0a1d4-a140-4db1-82e8-fcc21fdb49bb]
description = "4, being 5 - 1, is IV"
description = "4 is IV"

[57c0f9ad-5024-46ab-975d-de18c430b290]
description = "5 is a single V"
description = "5 is V"

[20a2b47f-e57f-4797-a541-0b3825d7f249]
description = "6, being 5 + 1, is VI"
description = "6 is VI"

[ff3fb08c-4917-4aab-9f4e-d663491d083d]
description = "9, being 10 - 1, is IX"
description = "9 is IX"

[6d1d82d5-bf3e-48af-9139-87d7165ed509]
description = "16 is XVI"

[2bda64ca-7d28-4c56-b08d-16ce65716cf6]
description = "20 is two X's"
description = "27 is XXVII"

[a1f812ef-84da-4e02-b4f0-89c907d0962c]
description = "48 is not 50 - 2 but rather 40 + 8"
description = "48 is XLVIII"

[607ead62-23d6-4c11-a396-ef821e2e5f75]
description = "49 is not 40 + 5 + 4 but rather 50 - 10 + 10 - 1"
description = "49 is XLIX"

[d5b283d4-455d-4e68-aacf-add6c4b51915]
description = "50 is a single L"
description = "59 is LIX"

[4465ffd5-34dc-44f3-ada5-56f5007b6dad]
description = "66 is LXVI"

[46b46e5b-24da-4180-bfe2-2ef30b39d0d0]
description = "90, being 100 - 10, is XC"
description = "93 is XCIII"

[30494be1-9afb-4f84-9d71-db9df18b55e3]
description = "100 is a single C"
description = "141 is CXLI"

[267f0207-3c55-459a-b81d-67cec7a46ed9]
description = "60, being 50 + 10, is LX"
description = "163 is CLXIII"

[902ad132-0b4d-40e3-8597-ba5ed611dd8d]
description = "166 is CLXVI"

[cdb06885-4485-4d71-8bfb-c9d0f496b404]
description = "400, being 500 - 100, is CD"
description = "402 is CDII"

[6b71841d-13b2-46b4-ba97-dec28133ea80]
description = "500 is a single D"
description = "575 is DLXXV"

[dacb84b9-ea1c-4a61-acbb-ce6b36674906]
description = "666 is DCLXVI"

[432de891-7fd6-4748-a7f6-156082eeca2f]
description = "900, being 1000 - 100, is CM"
description = "911 is CMXI"

[e6de6d24-f668-41c0-88d7-889c0254d173]
description = "1000 is a single M"
description = "1024 is MXXIV"

[efbe1d6a-9f98-4eb5-82bc-72753e3ac328]
description = "1666 is MDCLXVI"

[bb550038-d4eb-4be2-a9ce-f21961ac3bc6]
description = "3000 is three M's"
description = "3000 is MMM"

[3bc4b41c-c2e6-49d9-9142-420691504336]
description = "3001 is MMMI"

[2f89cad7-73f6-4d1b-857b-0ef531f68b7e]
description = "3888 is MMMDCCCLXXXVIII"

[4e18e96b-5fbb-43df-a91b-9cb511fe0856]
description = "3999 is MMMCMXCIX"
8 changes: 5 additions & 3 deletions exercises/practice/roman-numerals/src/roman_numerals.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns roman-numerals)

(defn numerals [] ;; <- arglist goes here
;; your code goes here
)
(defn numerals
"Convert a number to its roman numeral(s)"
[n]
;; function body
)
128 changes: 91 additions & 37 deletions exercises/practice/roman-numerals/test/roman_numerals_test.clj
Original file line number Diff line number Diff line change
@@ -1,57 +1,111 @@
(ns roman-numerals-test
(:require [clojure.test :refer [deftest is]]
(:require [clojure.test :refer [deftest testing is]]
roman-numerals))

(deftest one
(is (= "I" (roman-numerals/numerals 1))))
(deftest numerals_test_1
(testing "1 is I"
(is (= "I" (roman-numerals/numerals 1)))))

(deftest two
(is (= "II" (roman-numerals/numerals 2))))
(deftest numerals_test_2
(testing "2 is II"
(is (= "II" (roman-numerals/numerals 2)))))

(deftest three
(is (= "III" (roman-numerals/numerals 3))))
(deftest numerals_test_3
(testing "3 is III"
(is (= "III" (roman-numerals/numerals 3)))))

(deftest four
(is (= "IV" (roman-numerals/numerals 4))))
(deftest numerals_test_4
(testing "4 is IV"
(is (= "IV" (roman-numerals/numerals 4)))))

(deftest five
(is (= "V" (roman-numerals/numerals 5))))
(deftest numerals_test_5
(testing "5 is V"
(is (= "V" (roman-numerals/numerals 5)))))

(deftest six
(is (= "VI" (roman-numerals/numerals 6))))
(deftest numerals_test_6
(testing "6 is VI"
(is (= "VI" (roman-numerals/numerals 6)))))

(deftest nine
(is (= "IX" (roman-numerals/numerals 9))))
(deftest numerals_test_7
(testing "9 is IX"
(is (= "IX" (roman-numerals/numerals 9)))))

(deftest twenty-seven
(is (= "XXVII" (roman-numerals/numerals 27))))
(deftest numerals_test_8
(testing "16 is XVI"
(is (= "XVI" (roman-numerals/numerals 16)))))

(deftest forty-eight
(is (= "XLVIII" (roman-numerals/numerals 48))))
(deftest numerals_test_9
(testing "27 is XXVII"
(is (= "XXVII" (roman-numerals/numerals 27)))))

(deftest fifty-nine
(is (= "LIX" (roman-numerals/numerals 59))))
(deftest numerals_test_10
(testing "48 is XLVIII"
(is (= "XLVIII" (roman-numerals/numerals 48)))))

(deftest ninety-three
(is (= "XCIII" (roman-numerals/numerals 93))))
(deftest numerals_test_11
(testing "49 is XLIX"
(is (= "XLIX" (roman-numerals/numerals 49)))))

(deftest one-hundred-forty-one
(is (= "CXLI" (roman-numerals/numerals 141))))
(deftest numerals_test_12
(testing "59 is LIX"
(is (= "LIX" (roman-numerals/numerals 59)))))

(deftest one-hundred-sixty-three
(is (= "CLXIII" (roman-numerals/numerals 163))))
(deftest numerals_test_13
(testing "66 is LXVI"
(is (= "LXVI" (roman-numerals/numerals 66)))))

(deftest four-hundred-two
(is (= "CDII" (roman-numerals/numerals 402))))
(deftest numerals_test_14
(testing "93 is XCIII"
(is (= "XCIII" (roman-numerals/numerals 93)))))

(deftest five-hundred-seventy-five
(is (= "DLXXV" (roman-numerals/numerals 575))))
(deftest numerals_test_15
(testing "141 is CXLI"
(is (= "CXLI" (roman-numerals/numerals 141)))))

(deftest nine-hundred-eleven
(is (= "CMXI" (roman-numerals/numerals 911))))
(deftest numerals_test_16
(testing "163 is CLXIII"
(is (= "CLXIII" (roman-numerals/numerals 163)))))

(deftest one-thousand-twenty-four
(is (= "MXXIV" (roman-numerals/numerals 1024))))
(deftest numerals_test_17
(testing "166 is CLXVI"
(is (= "CLXVI" (roman-numerals/numerals 166)))))

(deftest three-thousand
(is (= "MMM" (roman-numerals/numerals 3000))))
(deftest numerals_test_18
(testing "402 is CDII"
(is (= "CDII" (roman-numerals/numerals 402)))))

(deftest numerals_test_19
(testing "575 is DLXXV"
(is (= "DLXXV" (roman-numerals/numerals 575)))))

(deftest numerals_test_20
(testing "666 is DCLXVI"
(is (= "DCLXVI" (roman-numerals/numerals 666)))))

(deftest numerals_test_21
(testing "911 is CMXI"
(is (= "CMXI" (roman-numerals/numerals 911)))))

(deftest numerals_test_22
(testing "1024 is MXXIV"
(is (= "MXXIV" (roman-numerals/numerals 1024)))))

(deftest numerals_test_23
(testing "1666 is MDCLXVI"
(is (= "MDCLXVI" (roman-numerals/numerals 1666)))))

(deftest numerals_test_24
(testing "3000 is MMM"
(is (= "MMM" (roman-numerals/numerals 3000)))))

(deftest numerals_test_25
(testing "3001 is MMMI"
(is (= "MMMI" (roman-numerals/numerals 3001)))))

(deftest numerals_test_26
(testing "3888 is MMMDCCCLXXXVIII"
(is (= "MMMDCCCLXXXVIII" (roman-numerals/numerals 3888)))))

(deftest numerals_test_27
(testing "3999 is MMMCMXCIX"
(is (= "MMMCMXCIX" (roman-numerals/numerals 3999)))))