Skip to content
9 changes: 6 additions & 3 deletions tdd_intro/homework/02_ternary_numbers/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ If your language provides a method in the standard library to perform the conver

int ConvertTernaryToDecimal(const std::string& ternaryNumber)
{
if(ternaryNumber == "012")
int sum = 0;
long value = 1;
for(int i = ternaryNumber.length() - 1; i >= 0; --i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

нет теста на пустую строку - следовательно не покрыт тестом кейс, когда цикл не выполнится ни разу

{
return 5;
sum += (ternaryNumber[i] - 48) * value;
value *= 3;
}

return std::stoi(ternaryNumber);
return sum;
}


Expand Down