Skip to content
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

2 ternary numbers #27

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

2 ternary numbers #27

wants to merge 23 commits into from

Conversation

ZakKurasov
Copy link

No description provided.

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.

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

@@ -19,7 +19,12 @@ If your language provides a method in the standard library to perform the conver

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
Слишком буквально это воспринял)))

{
result.push_back(ch - '0');
}
return result;
Copy link
Collaborator

Choose a reason for hiding this comment

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

тут также можно было бы использовать std::transform для наполения вектора:
http://www.cplusplus.com/reference/algorithm/transform/

    std::string in = "123";
    std::vector<int> out(3);
    std::transform(in.cbegin(), in.cend(), out.begin(), [] (char ch) { return ch - '0'; });
    EXPECT_EQ(std::vector<int>({1,2,3}), out);

Copy link
Author

Choose a reason for hiding this comment

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

Такая же ситуация как и выше)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants