Skip to content
Open
9 changes: 9 additions & 0 deletions tdd_intro/homework/02_ternary_numbers/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@ 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"));
Expand Down