ESGRAF48/test/Age.cpp

41 lines
773 B
C++
Raw Normal View History

#include <catch2/catch.hpp>
#include "Age.h"
TEST_CASE("default initialization")
{
2019-10-05 14:14:45 +00:00
Age age;
REQUIRE(age.years() == 0);
REQUIRE(age.months() == 0);
REQUIRE(age.toString() == "0;0");
Age age2;
REQUIRE(!(age < age));
REQUIRE(!(age < age2));
}
2018-11-24 19:08:01 +00:00
TEST_CASE("year/month initialization")
{
2019-10-05 14:14:45 +00:00
for (unsigned int year = 0; year <= 100; ++year)
{
for (unsigned int month = 0; month < 12; ++month)
{
Age age(year, month);
REQUIRE(age.years() == year);
REQUIRE(age.months() == month);
}
}
2018-11-24 19:08:01 +00:00
}
2018-11-25 13:30:45 +00:00
TEST_CASE("age by reference")
{
2019-10-05 14:14:45 +00:00
QDate birth(1970, 1, 1);
QDate reference(1980, 1, 1);
2018-11-25 13:30:45 +00:00
2019-10-05 14:14:45 +00:00
Age age(birth, reference);
2018-11-25 13:30:45 +00:00
2019-10-05 14:14:45 +00:00
REQUIRE(age.years() == 10);
REQUIRE(age.months() == 0);
2018-11-25 13:30:45 +00:00
}