-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync roman-numerals with problem-specifications (#1781)
- Loading branch information
Showing
3 changed files
with
265 additions
and
40 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
exercises/practice/roman-numerals/.meta/test_template.tera
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use roman_numerals::Roman; | ||
|
||
{% for test in cases %} | ||
#[test] | ||
{% if loop.index != 1 -%} | ||
#[ignore] | ||
{% endif -%} | ||
fn number_{{ test.description | slugify | replace(from="-", to="_") }}() { | ||
let input = {{ test.input.number | json_encode() }}; | ||
let output = Roman::from(input).to_string(); | ||
let expected = {{ test.expected | json_encode() }}; | ||
assert_eq!(output, expected); | ||
} | ||
{% endfor -%} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,88 @@ | ||
# 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 I" | ||
|
||
[f088f064-2d35-4476-9a41-f576da3f7b03] | ||
description = "2 is II" | ||
|
||
[b374a79c-3bea-43e6-8db8-1286f79c7106] | ||
description = "3 is III" | ||
|
||
[05a0a1d4-a140-4db1-82e8-fcc21fdb49bb] | ||
description = "4 is IV" | ||
|
||
[57c0f9ad-5024-46ab-975d-de18c430b290] | ||
description = "5 is V" | ||
|
||
[20a2b47f-e57f-4797-a541-0b3825d7f249] | ||
description = "6 is VI" | ||
|
||
[ff3fb08c-4917-4aab-9f4e-d663491d083d] | ||
description = "9 is IX" | ||
|
||
[6d1d82d5-bf3e-48af-9139-87d7165ed509] | ||
description = "16 is XVI" | ||
|
||
[2bda64ca-7d28-4c56-b08d-16ce65716cf6] | ||
description = "27 is XXVII" | ||
|
||
[a1f812ef-84da-4e02-b4f0-89c907d0962c] | ||
description = "48 is XLVIII" | ||
|
||
[607ead62-23d6-4c11-a396-ef821e2e5f75] | ||
description = "49 is XLIX" | ||
|
||
[d5b283d4-455d-4e68-aacf-add6c4b51915] | ||
description = "59 is LIX" | ||
|
||
[4465ffd5-34dc-44f3-ada5-56f5007b6dad] | ||
description = "66 is LXVI" | ||
|
||
[46b46e5b-24da-4180-bfe2-2ef30b39d0d0] | ||
description = "93 is XCIII" | ||
|
||
[30494be1-9afb-4f84-9d71-db9df18b55e3] | ||
description = "141 is CXLI" | ||
|
||
[267f0207-3c55-459a-b81d-67cec7a46ed9] | ||
description = "163 is CLXIII" | ||
|
||
[902ad132-0b4d-40e3-8597-ba5ed611dd8d] | ||
description = "166 is CLXVI" | ||
|
||
[cdb06885-4485-4d71-8bfb-c9d0f496b404] | ||
description = "402 is CDII" | ||
|
||
[6b71841d-13b2-46b4-ba97-dec28133ea80] | ||
description = "575 is DLXXV" | ||
|
||
[dacb84b9-ea1c-4a61-acbb-ce6b36674906] | ||
description = "666 is DCLXVI" | ||
|
||
[432de891-7fd6-4748-a7f6-156082eeca2f] | ||
description = "911 is CMXI" | ||
|
||
[e6de6d24-f668-41c0-88d7-889c0254d173] | ||
description = "1024 is MXXIV" | ||
|
||
[efbe1d6a-9f98-4eb5-82bc-72753e3ac328] | ||
description = "1666 is MDCLXVI" | ||
|
||
[bb550038-d4eb-4be2-a9ce-f21961ac3bc6] | ||
description = "3000 is MMM" | ||
|
||
[3bc4b41c-c2e6-49d9-9142-420691504336] | ||
description = "3001 is MMMI" | ||
|
||
[4e18e96b-5fbb-43df-a91b-9cb511fe0856] | ||
description = "3999 is MMMCMXCIX" |
200 changes: 163 additions & 37 deletions
200
exercises/practice/roman-numerals/tests/roman-numerals.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,234 @@ | ||
use roman_numerals::*; | ||
use roman_numerals::Roman; | ||
|
||
#[test] | ||
fn one() { | ||
assert_eq!("I", Roman::from(1).to_string()); | ||
fn number_1_is_i() { | ||
let input = 1; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "I"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn two() { | ||
assert_eq!("II", Roman::from(2).to_string()); | ||
fn number_2_is_ii() { | ||
let input = 2; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "II"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn three() { | ||
assert_eq!("III", Roman::from(3).to_string()); | ||
fn number_3_is_iii() { | ||
let input = 3; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "III"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn four() { | ||
assert_eq!("IV", Roman::from(4).to_string()); | ||
fn number_4_is_iv() { | ||
let input = 4; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "IV"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn five() { | ||
assert_eq!("V", Roman::from(5).to_string()); | ||
fn number_5_is_v() { | ||
let input = 5; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "V"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn six() { | ||
assert_eq!("VI", Roman::from(6).to_string()); | ||
fn number_6_is_vi() { | ||
let input = 6; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "VI"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn nine() { | ||
assert_eq!("IX", Roman::from(9).to_string()); | ||
fn number_9_is_ix() { | ||
let input = 9; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "IX"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn twenty_seven() { | ||
assert_eq!("XXVII", Roman::from(27).to_string()); | ||
fn number_16_is_xvi() { | ||
let input = 16; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "XVI"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn forty_eight() { | ||
assert_eq!("XLVIII", Roman::from(48).to_string()); | ||
fn number_27_is_xxvii() { | ||
let input = 27; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "XXVII"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn fifty_nine() { | ||
assert_eq!("LIX", Roman::from(59).to_string()); | ||
fn number_48_is_xlviii() { | ||
let input = 48; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "XLVIII"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn ninety_three() { | ||
assert_eq!("XCIII", Roman::from(93).to_string()); | ||
fn number_49_is_xlix() { | ||
let input = 49; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "XLIX"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_141() { | ||
assert_eq!("CXLI", Roman::from(141).to_string()); | ||
fn number_59_is_lix() { | ||
let input = 59; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "LIX"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_163() { | ||
assert_eq!("CLXIII", Roman::from(163).to_string()); | ||
fn number_66_is_lxvi() { | ||
let input = 66; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "LXVI"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_402() { | ||
assert_eq!("CDII", Roman::from(402).to_string()); | ||
fn number_93_is_xciii() { | ||
let input = 93; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "XCIII"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_575() { | ||
assert_eq!("DLXXV", Roman::from(575).to_string()); | ||
fn number_141_is_cxli() { | ||
let input = 141; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "CXLI"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_911() { | ||
assert_eq!("CMXI", Roman::from(911).to_string()); | ||
fn number_163_is_clxiii() { | ||
let input = 163; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "CLXIII"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_1024() { | ||
assert_eq!("MXXIV", Roman::from(1024).to_string()); | ||
fn number_166_is_clxvi() { | ||
let input = 166; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "CLXVI"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_3000() { | ||
assert_eq!("MMM", Roman::from(3000).to_string()); | ||
fn number_402_is_cdii() { | ||
let input = 402; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "CDII"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn number_575_is_dlxxv() { | ||
let input = 575; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "DLXXV"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn number_666_is_dclxvi() { | ||
let input = 666; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "DCLXVI"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn number_911_is_cmxi() { | ||
let input = 911; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "CMXI"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn number_1024_is_mxxiv() { | ||
let input = 1024; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "MXXIV"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn number_1666_is_mdclxvi() { | ||
let input = 1666; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "MDCLXVI"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn number_3000_is_mmm() { | ||
let input = 3000; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "MMM"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn number_3001_is_mmmi() { | ||
let input = 3001; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "MMMI"; | ||
assert_eq!(output, expected); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn number_3999_is_mmmcmxcix() { | ||
let input = 3999; | ||
let output = Roman::from(input).to_string(); | ||
let expected = "MMMCMXCIX"; | ||
assert_eq!(output, expected); | ||
} |