Skip to content

Commit

Permalink
Update tests for resistor-color-trio (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
BNAndras authored Aug 29, 2023
1 parent b8eb7b7 commit d7bcde5
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
28 changes: 25 additions & 3 deletions exercises/practice/resistor-color-trio/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# 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.

[d6863355-15b7-40bb-abe0-bfb1a25512ed]
description = "Orange and orange and black"
Expand All @@ -16,3 +23,18 @@ description = "Green and brown and orange"

[f5d37ef9-1919-4719-a90d-a33c5a6934c9]
description = "Yellow and violet and yellow"

[5f6404a7-5bb3-4283-877d-3d39bcc33854]
description = "Blue and violet and blue"

[7d3a6ab8-e40e-46c3-98b1-91639fff2344]
description = "Minimum possible value"

[ca0aa0ac-3825-42de-9f07-dac68cc580fd]
description = "Maximum possible value"

[0061a76c-903a-4714-8ce2-f26ce23b0e09]
description = "First two colors make an invalid octal number"

[30872c92-f567-4b69-a105-8455611c10c4]
description = "Ignore extra colors"
50 changes: 50 additions & 0 deletions exercises/practice/resistor-color-trio/test_resistor_color_trio.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,51 @@ static void test_yellow_violet_yellow(void)
TEST_ASSERT_EQUAL(KILOOHMS, actual.unit);
}

static void test_blue_violet_blue(void)
{
TEST_IGNORE();
resistor_value_t actual =
color_code((resistor_band_t[]){ BLUE, VIOLET, BLUE });
TEST_ASSERT_EQUAL_UINT16(67, actual.value);
TEST_ASSERT_EQUAL(MEGAOHMS, actual.unit);
}

static void test_minimum_possible_value(void)
{
TEST_IGNORE();
resistor_value_t actual =
color_code((resistor_band_t[]){ BLACK, BLACK, BLACK });
TEST_ASSERT_EQUAL_UINT16(0, actual.value);
TEST_ASSERT_EQUAL(OHMS, actual.unit);
}

static void test_maximum_possible_value(void)
{
TEST_IGNORE();
resistor_value_t actual =
color_code((resistor_band_t[]){ WHITE, WHITE, WHITE });
TEST_ASSERT_EQUAL_UINT16(99, actual.value);
TEST_ASSERT_EQUAL(GIGAOHMS, actual.unit);
}

static void test_invalid_octal(void)
{
TEST_IGNORE();
resistor_value_t actual =
color_code((resistor_band_t[]){ BLACK, GREY, BLACK });
TEST_ASSERT_EQUAL_UINT16(8, actual.value);
TEST_ASSERT_EQUAL(OHMS, actual.unit);
}

static void test_ignore_extra_colors(void)
{
TEST_IGNORE();
resistor_value_t actual =
color_code((resistor_band_t[]){ BLUE, GREEN, YELLOW, ORANGE });
TEST_ASSERT_EQUAL_UINT16(650, actual.value);
TEST_ASSERT_EQUAL(KILOOHMS, actual.unit);
}

int main(void)
{
UnityBegin("test_resistor_color_trio.c");
Expand All @@ -61,6 +106,11 @@ int main(void)
RUN_TEST(test_red_black_red);
RUN_TEST(test_green_brown_orange);
RUN_TEST(test_yellow_violet_yellow);
RUN_TEST(test_blue_violet_blue);
RUN_TEST(test_minimum_possible_value);
RUN_TEST(test_maximum_possible_value);
RUN_TEST(test_invalid_octal);
RUN_TEST(test_ignore_extra_colors);

return UnityEnd();
}

0 comments on commit d7bcde5

Please sign in to comment.