Skip to content

Conversation

@ZakKurasov
Copy link

No description provided.

Copy link
Collaborator

@mettizik mettizik left a comment

Choose a reason for hiding this comment

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

👍

TEST(SplitTest, ReturnSameWordForOneWordSentence)
TEST(SplitTest, ReturnsNWordsForNWordsSentenceSentence)
{
EXPECT_EQ(std::vector<std::string>({"word"}), Split("word", " "));
Copy link
Collaborator

Choose a reason for hiding this comment

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

этот экспект должен идти отдельно, поскольку изолирует отдельный кейс отсутствия делимитера

for (const std::string& word : words)
{
result.insert(std::make_pair(word, 1));
if (result.find(word) != result.end())
Copy link
Collaborator

Choose a reason for hiding this comment

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

можно упростить за счёт оператора [] в std::map:

result[word] += 1;

Он сделает вставку, если элемента нет, а в противном случае возьмет существующий

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