diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 4f186c8b..be5ce15d 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -13,3 +13,54 @@ If your language provides a method in the standard library that does this look-u */ #include + +bool IsLeapYear(int year) +{ + return (year % 100 == 0) ? (year % 400 == 0) : (year % 4 == 0); +} + +TEST(YearTest, OrdinaryYear) +{ + EXPECT_FALSE(IsLeapYear(1997)); +} + +TEST(YearTest, OrdinaryYearSecond) +{ + EXPECT_FALSE(IsLeapYear(1995)); +} + +TEST(YearTest, LeapYear) +{ + EXPECT_TRUE(IsLeapYear(1996)); +} + +TEST(YearTest, OrdinaryYearDerivedBy100) +{ + EXPECT_FALSE(IsLeapYear(1900)); +} + +TEST(YearTest, OrdinaryYearDerivedBy400) +{ + EXPECT_TRUE(IsLeapYear(2000)); +} + +TEST(YearTest, AcceptenceTest) +{ + EXPECT_TRUE(IsLeapYear(1952)); + EXPECT_TRUE(IsLeapYear(1956)); + EXPECT_TRUE(IsLeapYear(1960)); + EXPECT_TRUE(IsLeapYear(1964)); + EXPECT_TRUE(IsLeapYear(1968)); + EXPECT_TRUE(IsLeapYear(1972)); + EXPECT_TRUE(IsLeapYear(1976)); + + EXPECT_FALSE(IsLeapYear(1953)); + EXPECT_FALSE(IsLeapYear(1957)); + EXPECT_FALSE(IsLeapYear(1961)); + EXPECT_FALSE(IsLeapYear(421)); + EXPECT_FALSE(IsLeapYear(643)); + EXPECT_FALSE(IsLeapYear(121)); + EXPECT_FALSE(IsLeapYear(75)); + + ASSERT_NO_THROW(IsLeapYear(100)); +} diff --git a/tdd_intro/homework/04_weather_client/test.cpp b/tdd_intro/homework/04_weather_client/test.cpp index 346ea809..c180e75c 100644 --- a/tdd_intro/homework/04_weather_client/test.cpp +++ b/tdd_intro/homework/04_weather_client/test.cpp @@ -1,58 +1,50 @@ /* Weather Client - You are going to develop a program that gets the statistics about weather in the current city using information from a certain server. The goal is to calculate statistics using the data from weather server. - To communicate with the weather server you have to implement interface IWeatherServer, which provides the raw string from the real server for the requested day and time. - The real server (i.e. "weather.com") gets the requests in this format: ";