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

Updating new tests and rearranging tests for Roman-Numerals #1035

Merged
merged 2 commits into from
Jan 12, 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
1 change: 1 addition & 0 deletions exercises/practice/roman-numerals/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Gamecock",
"gea-migration",
"h-3-0",
"jagdish-15",
"patricksjackson",
"QLaille",
"ryanplusplus",
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/roman-numerals/.meta/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string.h>

#define NUM_OF_ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
#define MAX_NUMERAL_LENGTH (10)
#define MAX_NUMERAL_LENGTH (16)

typedef struct {
char *numeral;
Expand All @@ -18,7 +18,7 @@ const numeral_values_t numeral_values[] = {

char *to_roman_numeral(unsigned int number)
{
char *numerals = calloc(sizeof(char), MAX_NUMERAL_LENGTH);
char *numerals = calloc(1, sizeof(char) * (MAX_NUMERAL_LENGTH));

for (size_t i = 0; i < NUM_OF_ELEMENTS(numeral_values); i++) {
while (number >= numeral_values[i].value) {
Expand Down
33 changes: 18 additions & 15 deletions exercises/practice/roman-numerals/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ 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"

Expand All @@ -42,6 +45,9 @@ 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"

Expand All @@ -51,38 +57,35 @@ 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"

[bb550038-d4eb-4be2-a9ce-f21961ac3bc6]
description = "3000 is MMM"

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

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

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

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

[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"

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

[4e18e96b-5fbb-43df-a91b-9cb511fe0856]
description = "3999 is MMMCMXCIX"
69 changes: 38 additions & 31 deletions exercises/practice/roman-numerals/test_roman_numerals.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ static void test_9_is_IX(void)
check_conversion(9, "IX");
}

static void test_16_is_XVI(void)
{
TEST_IGNORE();
check_conversion(16, "XVI");
}

static void test_27_is_XXVII(void)
{
TEST_IGNORE();
Expand All @@ -86,6 +92,12 @@ static void test_59_is_LIX(void)
check_conversion(59, "LIX");
}

static void test_66_is_LXVI(void)
{
TEST_IGNORE();
check_conversion(66, "LXVI");
}

static void test_93_is_XCIII(void)
{
TEST_IGNORE();
Expand All @@ -104,70 +116,64 @@ static void test_163_is_CLXIII(void)
check_conversion(163, "CLXIII");
}

static void test_402_is_CDII(void)
{
TEST_IGNORE();
check_conversion(402, "CDII");
}

static void test_575_is_DLXXV(void)
static void test_166_is_CLXVI(void)
{
TEST_IGNORE();
check_conversion(575, "DLXXV");
check_conversion(166, "CLXVI");
}

static void test_911_is_CMXI(void)
static void test_402_is_CDII(void)
{
TEST_IGNORE();
check_conversion(911, "CMXI");
check_conversion(402, "CDII");
}

static void test_1024_is_MXXIV(void)
static void test_575_is_DLXXV(void)
{
TEST_IGNORE();
check_conversion(1024, "MXXIV");
check_conversion(575, "DLXXV");
}

static void test_3000_is_MMM(void)
static void test_666_is_DCLXVI(void)
{
TEST_IGNORE();
check_conversion(3000, "MMM");
check_conversion(666, "DCLXVI");
}

static void test_16_is_XVI(void)
static void test_911_is_CMXI(void)
{
TEST_IGNORE();
check_conversion(16, "XVI");
check_conversion(911, "CMXI");
}

static void test_66_is_LXVI(void)
static void test_1024_is_MXXIV(void)
{
TEST_IGNORE();
check_conversion(66, "LXVI");
check_conversion(1024, "MXXIV");
}

static void test_166_is_CLXVI(void)
static void test_1666_is_MDCLXVI(void)
{
TEST_IGNORE();
check_conversion(166, "CLXVI");
check_conversion(1666, "MDCLXVI");
}

static void test_666_is_DCLXVI(void)
static void test_3000_is_MMM(void)
{
TEST_IGNORE();
check_conversion(666, "DCLXVI");
check_conversion(3000, "MMM");
}

static void test_1666_is_MDCLXVI(void)
static void test_3001_is_MMMI(void)
{
TEST_IGNORE();
check_conversion(1666, "MDCLXVI");
check_conversion(3001, "MMMI");
}

static void test_3001_is_MMMI(void)
static void test_3888_is_MMMDCCCLXXXVIII(void)
{
TEST_IGNORE();
check_conversion(3001, "MMMI");
check_conversion(3888, "MMMDCCCLXXXVIII");
}

static void test_3999_is_MMMCMXCIX(void)
Expand All @@ -187,24 +193,25 @@ int main(void)
RUN_TEST(test_5_is_V);
RUN_TEST(test_6_is_VI);
RUN_TEST(test_9_is_IX);
RUN_TEST(test_16_is_XVI);
RUN_TEST(test_27_is_XXVII);
RUN_TEST(test_48_is_XLVIII);
RUN_TEST(test_49_is_XLIX);
RUN_TEST(test_59_is_LIX);
RUN_TEST(test_66_is_LXVI);
RUN_TEST(test_93_is_XCIII);
RUN_TEST(test_141_is_CXLI);
RUN_TEST(test_163_is_CLXIII);
RUN_TEST(test_166_is_CLXVI);
RUN_TEST(test_402_is_CDII);
RUN_TEST(test_575_is_DLXXV);
RUN_TEST(test_666_is_DCLXVI);
RUN_TEST(test_911_is_CMXI);
RUN_TEST(test_1024_is_MXXIV);
RUN_TEST(test_3000_is_MMM);
RUN_TEST(test_16_is_XVI);
RUN_TEST(test_66_is_LXVI);
RUN_TEST(test_166_is_CLXVI);
RUN_TEST(test_666_is_DCLXVI);
RUN_TEST(test_1666_is_MDCLXVI);
RUN_TEST(test_3000_is_MMM);
RUN_TEST(test_3001_is_MMMI);
RUN_TEST(test_3888_is_MMMDCCCLXXXVIII);
RUN_TEST(test_3999_is_MMMCMXCIX);

return UNITY_END();
Expand Down