january = 1
december = 12
on leap year, february has 29 days, 28 otherwise
int nbDaysInMonth(int month, bool leap)
{
return 31 - (month % 2 == (month > 7)) - (month == 2) * (2 - leap);
}
// TODO: Replace examples and use TDD by writing your own tests
Describe(any_group_name_you_want)
{
It(should_do_something)
{
Assert::That(nbDaysInMonth(1, false), Equals(31)); // January
Assert::That(nbDaysInMonth(2, false), Equals(28)); // February
Assert::That(nbDaysInMonth(2, true), Equals(29)); // February on leap year
Assert::That(nbDaysInMonth(3, false), Equals(31)); // March
Assert::That(nbDaysInMonth(4, false), Equals(30)); // April
Assert::That(nbDaysInMonth(5, false), Equals(31)); // May
Assert::That(nbDaysInMonth(6, false), Equals(30)); // June
Assert::That(nbDaysInMonth(7, false), Equals(31)); // July
Assert::That(nbDaysInMonth(8, false), Equals(31)); // August
Assert::That(nbDaysInMonth(9, false), Equals(30)); // September
Assert::That(nbDaysInMonth(10, false), Equals(31)); // October
Assert::That(nbDaysInMonth(11, false), Equals(30)); // November
Assert::That(nbDaysInMonth(12, false), Equals(31)); // December
}
};