-
Notifications
You must be signed in to change notification settings - Fork 1
01 leap year homework #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 12 commits
8de7e8c
fcf17c0
fbfe3fe
af1ef20
355005d
f6b0c24
aa304e0
46bab5b
81ae4ff
012ec88
6131814
6d63ef1
1d1530b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,48 @@ If your language provides a method in the standard library that does this look-u | |
| */ | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| bool is_leap_year(uint32_t year) | ||
| { | ||
| if (year % 4 == 0) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. какие были подставы для рефакторинга? тестов я не видел
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. При додані нового теста докостилювалися нові умови в if. Це хіба не підстава для рефакторинга?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. да, но в коммите я не видел тестов, предыдущее изменение тоже рефакторинг
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А до якого коміта прив'язані ці коменти? Бо в мене попередній коміт - це фікс теста для 4. І після теста я зарефакторив умову, тому що всі попередні числа ділились на 4. |
||
| { | ||
| if (year % 100 == 0) | ||
| { | ||
| year /= 100; | ||
| return is_leap_year(year); | ||
| } | ||
| else | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| TEST(leap_year, test_1997) | ||
| { | ||
| EXPECT_EQ(false, is_leap_year(1997)); | ||
| } | ||
|
|
||
| TEST(leap_year, test_1996) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. название теста ни о чем не говорит. Из этого имени нельзя понять, что действительно разработчик хочет проверить |
||
| { | ||
| EXPECT_EQ(true, is_leap_year(1996)); | ||
| } | ||
|
|
||
| TEST(leap_year, test_1990) | ||
| { | ||
| EXPECT_EQ(false, is_leap_year(1990)); | ||
| } | ||
|
|
||
| TEST(leap_year, test_2000) | ||
| { | ||
| EXPECT_EQ(true, is_leap_year(2000)); | ||
| } | ||
|
|
||
| TEST(leap_year, test_4) | ||
| { | ||
| EXPECT_EQ(true, is_leap_year(4)); | ||
| } | ||
|
|
||
| TEST(leap_year, test_100) | ||
| { | ||
| EXPECT_EQ(false, is_leap_year(100)); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
финальный рефакторинг не закончен, окончательный вариант функции +- вот таким может быть
return (year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Але ж це не найпростіше рішення на даному етапі
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это был бы последний этап - самый последний рефакторинг