From d7bcde5b418c7fd49ab0a2a50cefc420bce377d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Tue, 29 Aug 2023 04:30:16 -0700 Subject: [PATCH] Update tests for resistor-color-trio (#915) --- .../resistor-color-trio/.meta/tests.toml | 28 +++++++++-- .../test_resistor_color_trio.c | 50 +++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/exercises/practice/resistor-color-trio/.meta/tests.toml b/exercises/practice/resistor-color-trio/.meta/tests.toml index beabab3df..b7d45fa5d 100644 --- a/exercises/practice/resistor-color-trio/.meta/tests.toml +++ b/exercises/practice/resistor-color-trio/.meta/tests.toml @@ -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" @@ -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" diff --git a/exercises/practice/resistor-color-trio/test_resistor_color_trio.c b/exercises/practice/resistor-color-trio/test_resistor_color_trio.c index 1b641c86b..df44bbd25 100644 --- a/exercises/practice/resistor-color-trio/test_resistor_color_trio.c +++ b/exercises/practice/resistor-color-trio/test_resistor_color_trio.c @@ -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"); @@ -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(); }