Skip to content

Commit

Permalink
Update hamming.bats
Browse files Browse the repository at this point in the history
A test was added to fail if the script accepts more than two arguments, because the exercise description specifies that exactly two arguments of equal length must be passed.
  • Loading branch information
pedrobotolli authored Sep 9, 2024
1 parent 71ab190 commit 7e3d6d1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions exercises/practice/hamming/hamming.bats
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ load bats-extra
assert_output "Usage: hamming.sh <string1> <string2>"
}

@test "invalid input (more than 2 arguments)" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash hamming.sh 'A' 'A' 'A'
assert_failure
assert_output "Usage: hamming.sh <string1> <string2>"
}

# Within [[...]] the == operator is a _pattern matching_ operator.
# To test for string equality, the right-hand side must be
# quoted to prevent interpretation as a glob-style pattern.
Expand Down

0 comments on commit 7e3d6d1

Please sign in to comment.