Skip to content
16 changes: 16 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,19 @@ 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 ConvertTernaryToDecimal(const std::string& ternaryNumber)
{
return std::stoi(ternaryNumber);
}


TEST(TernaryNumber, OneConvertsToOneTest)
{
EXPECT_EQ(1, ConvertTernaryToDecimal("1"));
}

TEST(TernaryNumber, ConvertValidTernaryNumberTest)
{
EXPECT_EQ(5, ConvertTernaryToDecimal("012"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Можно было сначала добавить тест на невалидное значение.
Шаг выглядит великоватым.

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • перед этим тестом нужен был тест с пустой строкой

}