From 6730550e91e5a21f222c4742305a3edf9e034a47 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 17:58:58 +0300 Subject: [PATCH 01/40] Red: Initial test - ordinary year --- tdd_intro/homework/01_leap_year/test.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 4f186c8b..7559cf91 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -13,3 +13,8 @@ If your language provides a method in the standard library that does this look-u */ #include + +TEST(YearTest, OrdinaryYear) +{ + EXPECT_FALSE(IsLeapYear(1997)); +} From 18c2904eaf1189e8dcba04cc18744058424cc1e9 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:00:17 +0300 Subject: [PATCH 02/40] Green: Ordinary year --- tdd_intro/homework/01_leap_year/test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 7559cf91..4744955c 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -14,6 +14,15 @@ If your language provides a method in the standard library that does this look-u #include +bool IsLeapYear(int year) +{ + if (year == 1997) + { + return false; + } + return true; +} + TEST(YearTest, OrdinaryYear) { EXPECT_FALSE(IsLeapYear(1997)); From 787f8bfc09e5eb17a6b34ec2860f31516513780d Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:01:14 +0300 Subject: [PATCH 03/40] Red: Leap year --- tdd_intro/homework/01_leap_year/test.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 4744955c..60f3381e 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -27,3 +27,8 @@ TEST(YearTest, OrdinaryYear) { EXPECT_FALSE(IsLeapYear(1997)); } + +TEST(YearTest, LeapYear) +{ + EXPECT_TRUE(IsLeapYear(1996)); +} From a11772106512b8eae5a5606b588255c70aac955c Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:06:30 +0300 Subject: [PATCH 04/40] Really Red: second ordinary year --- tdd_intro/homework/01_leap_year/test.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 60f3381e..dc168e0f 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -20,7 +20,10 @@ bool IsLeapYear(int year) { return false; } - return true; + else + { + return true; + } } TEST(YearTest, OrdinaryYear) @@ -28,6 +31,11 @@ TEST(YearTest, OrdinaryYear) EXPECT_FALSE(IsLeapYear(1997)); } +TEST(YearTest, OrdinaryYearSecond) +{ + EXPECT_FALSE(IsLeapYear(1995)); +} + TEST(YearTest, LeapYear) { EXPECT_TRUE(IsLeapYear(1996)); From 32be5f66f8e5c709fae8f30951a56ba8bcd72cd2 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:07:26 +0300 Subject: [PATCH 05/40] Green: second ordinary year --- tdd_intro/homework/01_leap_year/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index dc168e0f..3c1c60db 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -16,7 +16,7 @@ If your language provides a method in the standard library that does this look-u bool IsLeapYear(int year) { - if (year == 1997) + if (year == 1997 || year == 1995) { return false; } From 9b13cffbcaeec478d5a8b2facfc9179fb98396c0 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:08:19 +0300 Subject: [PATCH 06/40] First refactoring --- tdd_intro/homework/01_leap_year/test.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 3c1c60db..62a038c6 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -16,14 +16,7 @@ If your language provides a method in the standard library that does this look-u bool IsLeapYear(int year) { - if (year == 1997 || year == 1995) - { - return false; - } - else - { - return true; - } + return year % 4 == 0; } TEST(YearTest, OrdinaryYear) From 20cf4749fd5ec165e8d7cbc69b3d0f88a1f7ddf9 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:09:19 +0300 Subject: [PATCH 07/40] Red: ordinary year derived by 100 --- tdd_intro/homework/01_leap_year/test.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 62a038c6..a8c79f4c 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -33,3 +33,9 @@ TEST(YearTest, LeapYear) { EXPECT_TRUE(IsLeapYear(1996)); } + +TEST(YearTest, OrdinaryYearDerivedBy100) +{ + EXPECT_FALSE(IsLeapYear(1900)); +} + From f7b8aa942c24c123cb1e513555c91bfc12dfe3e5 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:12:22 +0300 Subject: [PATCH 08/40] Green: ordinary year derived by 100 --- tdd_intro/homework/01_leap_year/test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index a8c79f4c..557bd2d1 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -16,6 +16,10 @@ If your language provides a method in the standard library that does this look-u bool IsLeapYear(int year) { + if (year % 100 == 0) + { + return false; + } return year % 4 == 0; } From 72f75c3efe0062f597bd25c6922ad2b92db3f1c6 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:13:16 +0300 Subject: [PATCH 09/40] Red: leap year derived by 400 --- tdd_intro/homework/01_leap_year/test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 557bd2d1..16837e12 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -43,3 +43,7 @@ TEST(YearTest, OrdinaryYearDerivedBy100) EXPECT_FALSE(IsLeapYear(1900)); } +TEST(YearTest, OrdinaryYearDerivedBy400) +{ + EXPECT_TRUE(IsLeapYear(2000)); +} From ccc746aa86de24cec0b9236f0bb493e3a4a854d9 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:14:11 +0300 Subject: [PATCH 10/40] Green: leap year derived by 400 --- tdd_intro/homework/01_leap_year/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 16837e12..b29f352a 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -16,7 +16,7 @@ If your language provides a method in the standard library that does this look-u bool IsLeapYear(int year) { - if (year % 100 == 0) + if (year % 100 == 0 && year % 400 != 0) { return false; } From 2de5f435f0055ee336a1316a5a8436d46e415efa Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:17:04 +0300 Subject: [PATCH 11/40] Second Refactoring --- tdd_intro/homework/01_leap_year/test.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index b29f352a..8f600546 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -16,11 +16,7 @@ If your language provides a method in the standard library that does this look-u bool IsLeapYear(int year) { - if (year % 100 == 0 && year % 400 != 0) - { - return false; - } - return year % 4 == 0; + return (year % 100 == 0) ? (year % 400 == 0) : (year % 4 == 0); } TEST(YearTest, OrdinaryYear) From 25d20eb8c2209e12435bdf7fe9ecaef641574376 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 4 Oct 2018 18:23:01 +0300 Subject: [PATCH 12/40] Green: acceptance test --- tdd_intro/homework/01_leap_year/test.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 8f600546..be5ce15d 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -43,3 +43,24 @@ 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)); +} From 71de85fddbcab4713bad5ac6afe2bed691c052a3 Mon Sep 17 00:00:00 2001 From: Vladislavru Date: Thu, 25 Oct 2018 04:40:29 +0300 Subject: [PATCH 13/40] test list --- tdd_intro/homework/04_weather_client/test.cpp | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tdd_intro/homework/04_weather_client/test.cpp b/tdd_intro/homework/04_weather_client/test.cpp index 346ea809..afb60d40 100644 --- a/tdd_intro/homework/04_weather_client/test.cpp +++ b/tdd_intro/homework/04_weather_client/test.cpp @@ -1,46 +1,36 @@ /* 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: ";