1
1
Fork 0
exercism/jq/proverb/test-proverb.bats
Christina Sørensen ca6b099b05
feat(jq): proverb
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
2024-12-18 06:10:13 +01:00

111 lines
2.3 KiB
Bash

#!/usr/bin/env bats
# generated on 2022-11-02T20:59:37Z
load bats-extra
load bats-jq
@test 'zero pieces' {
#
run jq -c -f proverb.jq << 'END_INPUT'
{
"strings": []
}
END_INPUT
assert_success
expected='[]'
assert_equal "$output" "$expected"
}
@test 'one piece' {
run jq -c -f proverb.jq << 'END_INPUT'
{
"strings": [
"nail"
]
}
END_INPUT
assert_success
expected='["And all for the want of a nail."]'
assert_equal "$output" "$expected"
}
@test 'two pieces' {
run jq -c -f proverb.jq << 'END_INPUT'
{
"strings": [
"nail",
"shoe"
]
}
END_INPUT
assert_success
expected='["For want of a nail the shoe was lost.","And all for the want of a nail."]'
assert_equal "$output" "$expected"
}
@test 'three pieces' {
run jq -c -f proverb.jq << 'END_INPUT'
{
"strings": [
"nail",
"shoe",
"horse"
]
}
END_INPUT
assert_success
expected='["For want of a nail the shoe was lost.","For want of a shoe the horse was lost.","And all for the want of a nail."]'
assert_equal "$output" "$expected"
}
@test 'full proverb' {
run jq -c -f proverb.jq << 'END_INPUT'
{
"strings": [
"nail",
"shoe",
"horse",
"rider",
"message",
"battle",
"kingdom"
]
}
END_INPUT
assert_success
expected='["For want of a nail the shoe was lost.","For want of a shoe the horse was lost.","For want of a horse the rider was lost.","For want of a rider the message was lost.","For want of a message the battle was lost.","For want of a battle the kingdom was lost.","And all for the want of a nail."]'
assert_equal "$output" "$expected"
}
@test 'four pieces modernized' {
run jq -c -f proverb.jq << 'END_INPUT'
{
"strings": [
"pin",
"gun",
"soldier",
"battle"
]
}
END_INPUT
assert_success
expected='["For want of a pin the gun was lost.","For want of a gun the soldier was lost.","For want of a soldier the battle was lost.","And all for the want of a pin."]'
assert_equal "$output" "$expected"
}