1
Fork 0
romantic/tests/default.rs

41 lines
1.2 KiB
Rust

use romantic::Roman;
use test_case::test_case;
#[test_case(0, ""; "empty")]
#[test_case(3888, "MMMDCCCLXXXVIII"; "all characters")]
#[test_case(3999, "MMMCMXCIX"; "maximum")]
#[test_case(1, "I"; "one")]
#[test_case(2, "II"; "two")]
#[test_case(3, "III"; "three")]
#[test_case(4, "IV"; "four")]
#[test_case(5, "V"; "five")]
#[test_case(6, "VI"; "six")]
#[test_case(7, "VII"; "seven")]
#[test_case(8, "VIII"; "eight")]
#[test_case(9, "IX"; "nine")]
#[test_case(10, "X"; "ten")]
fn test_to_string<T: num::PrimInt + num::Signed + ToString>(
input: T,
expected: &str,
) {
assert_eq!(Roman::default().to_string(input).unwrap(), expected);
}
#[test_case("", 0; "empty")]
#[test_case("MMMDCCCLXXXVIII", 3888; "complicated")]
#[test_case("MMMCMXCIX", 3999; "maximum")]
#[test_case("I", 1; "one")]
#[test_case("II", 2; "two")]
#[test_case("III", 3; "three")]
#[test_case("IV", 4; "four")]
#[test_case("V", 5; "five")]
#[test_case("VI", 6; "six")]
#[test_case("VII", 7; "seven")]
#[test_case("VIII", 8; "eight")]
#[test_case("IX", 9; "nine")]
#[test_case("X", 10; "ten")]
fn test_from_str(input: &str, expected: i32) {
assert_eq!(Roman::default().from_str::<i32>(input).unwrap(), expected);
}