diff options
author | Tobias Christiansen <tobi@tobyase.de> | 2021-07-04 20:33:58 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-04 22:17:03 +0200 |
commit | f35c25a7eb331a4ee4252ffac82393e4cf36714f (patch) | |
tree | f746cbeecc6945a92f079dcbfc18397cddba9b5e | |
parent | 36a420a6a66d61a63de00a06c350637222a8f62d (diff) | |
download | serenity-f35c25a7eb331a4ee4252ffac82393e4cf36714f.zip |
Tests: Add test for String::roman_number_from()
-rw-r--r-- | Tests/AK/TestString.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Tests/AK/TestString.cpp b/Tests/AK/TestString.cpp index 418027a27b..df4a87afca 100644 --- a/Tests/AK/TestString.cpp +++ b/Tests/AK/TestString.cpp @@ -282,3 +282,24 @@ TEST_CASE(find_with_empty_needle) EXPECT_EQ(string.find(""sv), 0u); EXPECT_EQ(string.find_all(""sv), (Vector<size_t> { 0u, 1u, 2u, 3u })); } + +TEST_CASE(roman_numerals) +{ + auto zero = String::roman_number_from(0); + EXPECT_EQ(zero, ""); + + auto one = String::roman_number_from(1); + EXPECT_EQ(one, "I"); + + auto nine = String::roman_number_from(9); + EXPECT_EQ(nine, "IX"); + + auto fourty_eight = String::roman_number_from(48); + EXPECT_EQ(fourty_eight, "XLVIII"); + + auto one_thousand_nine_hundred_ninety_eight = String::roman_number_from(1998); + EXPECT_EQ(one_thousand_nine_hundred_ninety_eight, "MCMXCVIII"); + + auto four_thousand = String::roman_number_from(4000); + EXPECT_EQ(four_thousand, "4000"); +} |