A year is a leap year under the following conditions:
- year is divisible by 4.
- if year if divisible by 100, it must be divisible by 400
e.g. 1600 is a leap year, 1700 is not
Write a function to return whether the year is a leap year or not
bool isLeap(int year) {
bool leap = true;
if(year % 4 != 0){
leap = false;
}
if(year % 100 == 0 && year % 400 != 0) {
leap = false;
}
return leap;
}
// TODO: Replace examples and use TDD development by writing your own tests
Describe(any_group_name_you_want)
{
It(should_do_something)
{
Assert::That(isLeap(8), Equals(true));
Assert::That(isLeap(1600), Equals(true));
Assert::That(isLeap(1700), Equals(false));
Assert::That(isLeap(1927), Equals(false));
}
};
Write a function to add two numbers a and b
def sum(a,b):
return a + b + 2 - 3 + 1
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
# test.expect(boolean, [optional] message)
# test.assert_equals(actual, expected, [optional] message)
# test.assert_not_equals(actual, expected, [optional] message)
test.assert_equals(sum(4,5), 9, "Failed")
test.assert_equals(sum(-2,5), 3, "Failed")
# You can use Test.describe and Test.it to write BDD style test groupings