1
1
Fork 0
exercism/jq/leap/test-leap.bats
Christina Sørensen 1e351d9c3e
feat(jq): two-fer, resistor-color, resistor-color-duo, leap, isogram, flatten-array
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
2024-12-16 08:26:51 +01:00

131 lines
2.2 KiB
Bash

#!/usr/bin/env bats
# generated on 2022-11-02T20:59:17Z
load bats-extra
load bats-jq
@test 'year not divisible by 4 in common year' {
#
run jq -r -f leap.jq << 'END_INPUT'
{
"year": 2015
}
END_INPUT
assert_success
expected=false
assert_equal "$output" "$expected"
}
@test 'year divisible by 2, not divisible by 4 in common year' {
run jq -r -f leap.jq << 'END_INPUT'
{
"year": 1970
}
END_INPUT
assert_success
expected=false
assert_equal "$output" "$expected"
}
@test 'year divisible by 4, not divisible by 100 in leap year' {
run jq -r -f leap.jq << 'END_INPUT'
{
"year": 1996
}
END_INPUT
assert_success
expected=true
assert_equal "$output" "$expected"
}
@test 'year divisible by 4 and 5 is still a leap year' {
run jq -r -f leap.jq << 'END_INPUT'
{
"year": 1960
}
END_INPUT
assert_success
expected=true
assert_equal "$output" "$expected"
}
@test 'year divisible by 100, not divisible by 400 in common year' {
run jq -r -f leap.jq << 'END_INPUT'
{
"year": 2100
}
END_INPUT
assert_success
expected=false
assert_equal "$output" "$expected"
}
@test 'year divisible by 100 but not by 3 is still not a leap year' {
run jq -r -f leap.jq << 'END_INPUT'
{
"year": 1900
}
END_INPUT
assert_success
expected=false
assert_equal "$output" "$expected"
}
@test 'year divisible by 400 is leap year' {
run jq -r -f leap.jq << 'END_INPUT'
{
"year": 2000
}
END_INPUT
assert_success
expected=true
assert_equal "$output" "$expected"
}
@test 'year divisible by 400 but not by 125 is still a leap year' {
run jq -r -f leap.jq << 'END_INPUT'
{
"year": 2400
}
END_INPUT
assert_success
expected=true
assert_equal "$output" "$expected"
}
@test 'year divisible by 200, not divisible by 400 in common year' {
run jq -r -f leap.jq << 'END_INPUT'
{
"year": 1800
}
END_INPUT
assert_success
expected=false
assert_equal "$output" "$expected"
}