Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@
*.exe
*.out
*.app

# Build dirs
build-*

# .user files
*.user
27 changes: 27 additions & 0 deletions tdd_intro/homework/02_ternary_numbers/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,30 @@ The last place in a ternary number is the 1's place. The second to last is the 3

If your language provides a method in the standard library to perform the conversion, pretend it doesn't exist and implement it yourself.
*/

int Power(int number, int index)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::pow уже сделал это за нас :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If your language provides a method in the standard library
Слишком буквально это воспринял)))

{
return 0;
}
int TerToDec(const std::string& ternary)
{
return std::stoi(ternary);
}

TEST(PowerTest, ItReturnSameNumberForIndexOne)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

по канонам TDD у теья не должно висеть красных тестов на протяжении долгого времени. Если ты написал тест, который требует доп реализации и прохождения других тестов сначала - тест следует убрать или задизэйблить. У Google Test есть такая фича - https://stackoverflow.com/a/7208119/5607187

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Понял, спасибо)

{
EXPECT_EQ(5, Power(5, 1));
}

TEST(TerToDecTest, ItReturnsOneForOne)
{
EXPECT_EQ(1, TerToDec("1"));
}
TEST(TerToDecTest, ItReturnsZeroForZero)
{
EXPECT_EQ(0, TerToDec("0"));
}
TEST(TerToDecTest, ItReturnsDecRepresentationForTwoDigitNumber)
{
EXPECT_EQ(4, TerToDec("11"));
}