-
Notifications
You must be signed in to change notification settings - Fork 17
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
Ternary number #8
base: master
Are you sure you want to change the base?
Conversation
|
||
TEST(TernaryNumber, ConvertValidTernaryNumberTest) | ||
{ | ||
EXPECT_EQ(5, ConvertTernaryToDecimal("012")); |
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.
- перед этим тестом нужен был тест с пустой строкой
@@ -28,6 +28,11 @@ int ConvertTernaryToDecimal(const std::string& ternaryNumber) | |||
|
|||
for(int i = numberLen - 1; i >= 0; --i) | |||
{ | |||
int currentSymbol = static_cast<int>(ternaryNumber[i]) - s_ascii_shift; | |||
if(currentSymbol > 3 || currentSymbol < 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.
Не соответствует условию задачи:
Trinary numbers contain three symbols: 0, 1, and 2.
if(ternaryNumber == "012") | ||
int sum = 0; | ||
long value = 1; | ||
for(int i = ternaryNumber.length() - 1; i >= 0; --i) |
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.
нет теста на пустую строку - следовательно не покрыт тестом кейс, когда цикл не выполнится ни разу
No description provided.