Added more Age-class tests

This commit is contained in:
Michael Mandl 2018-11-25 14:30:45 +01:00
parent 09f8fa4faf
commit 220f92453d
2 changed files with 17 additions and 6 deletions

View file

@ -4,8 +4,8 @@
#include <sstream> #include <sstream>
Age::Age(unsigned int years, unsigned int months) Age::Age(unsigned int years, unsigned int months)
: m_years(years) : m_years(years)
, m_months(months) , m_months(months)
{ {
} }

View file

@ -18,7 +18,7 @@ TEST_CASE("year/month initialization")
{ {
for (unsigned int year = 0; year <= 100; ++year) for (unsigned int year = 0; year <= 100; ++year)
{ {
for (unsigned int month = 1; month <= 12; ++month) for (unsigned int month = 0; month < 12; ++month)
{ {
Age age(year, month); Age age(year, month);
@ -27,3 +27,14 @@ TEST_CASE("year/month initialization")
} }
} }
} }
TEST_CASE("age by reference")
{
QDate birth(1970, 1, 1);
QDate reference(1980, 1, 1);
Age age(birth, reference);
REQUIRE(age.years() == 10);
REQUIRE(age.months() == 0);
}