diff --git a/exercises/practice/resistor-color-trio/.meta/template.j2 b/exercises/practice/resistor-color-trio/.meta/template.j2 new file mode 100644 index 00000000..13c353e3 --- /dev/null +++ b/exercises/practice/resistor-color-trio/.meta/template.j2 @@ -0,0 +1,30 @@ +{{ header }} +{% for idx, case in cases %} +@test "{{ case["description"] }}" { + {% if idx == 0 %}# {% endif %}[[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash {{ solution }} "{{ case["input"]["colors"] | join('" "') }}" + assert_success + assert_output "{{ case["expected"]["value"] }} {{ case["expected"]["unit"] }}" +} +{% endfor %} + +@test "Invalid first color" { + [[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash {{ solution }} "foo" "white" "white" + assert_failure + assert_output # there is _some_ output +} + +@test "Invalid second color" { + [[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash {{ solution }} "white" "bar" "white" + assert_failure + assert_output # there is _some_ output +} + +@test "Invalid third color" { + [[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash {{ solution }} "white" "white" "baz" + assert_failure + assert_output # there is _some_ output +} diff --git a/exercises/practice/resistor-color-trio/resistor_color_trio.bats b/exercises/practice/resistor-color-trio/resistor_color_trio.bats index cfcbe0c5..20aaeb84 100644 --- a/exercises/practice/resistor-color-trio/resistor_color_trio.bats +++ b/exercises/practice/resistor-color-trio/resistor_color_trio.bats @@ -1,11 +1,11 @@ #!/usr/bin/env bats load bats-extra -# local version: 1.0.0.2 -# additional tests for: invalid color, invalid octal number, too many colors +# generated on 2026-06-29T06:21:03+00:00 +# local version: 2.0.0.0 @test "Orange and orange and black" { - #[[ $BATS_RUN_SKIPPED == "true" ]] || skip + # [[ $BATS_RUN_SKIPPED == "true" ]] || skip run bash resistor_color_trio.sh "orange" "orange" "black" assert_success assert_output "33 ohms" @@ -18,13 +18,6 @@ load bats-extra assert_output "680 ohms" } -@test "Brown and red and red" { - [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash resistor_color_trio.sh "brown" "red" "red" - assert_success - assert_output "1200 ohms" -} - @test "Red and black and red" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip run bash resistor_color_trio.sh "red" "black" "red" @@ -46,7 +39,7 @@ load bats-extra assert_output "470 kiloohms" } -@test "Blue and violet and grey" { +@test "Blue and violet and blue" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip run bash resistor_color_trio.sh "blue" "violet" "blue" assert_success @@ -67,6 +60,20 @@ load bats-extra assert_output "99 gigaohms" } +@test "First two colors make an invalid octal number" { + [[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash resistor_color_trio.sh "black" "grey" "black" + assert_success + assert_output "8 ohms" +} + +@test "Ignore extra colors" { + [[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash resistor_color_trio.sh "blue" "green" "yellow" "orange" + assert_success + assert_output "650 kiloohms" +} + @test "Invalid first color" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip @@ -88,17 +95,3 @@ load bats-extra assert_failure assert_output # there is _some_ output } - -@test "First two colors make an invalid octal number" { - [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash resistor_color_trio.sh "black" "grey" "black" - assert_success - assert_output "8 ohms" -} - -@test "Ignore extra colors" { - [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash resistor_color_trio.sh "blue" "green" "yellow" "orange" - assert_success - assert_output "650 kiloohms" -}