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

init calculator unit test #10

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

init calculator unit test #10

wants to merge 15 commits into from

Conversation

GoranShekerov
Copy link

TDD / extreame programing try

TDD / extreame programing try
test/project_test.cc Outdated Show resolved Hide resolved
continue;
}

if (isOperator(token.at(0))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest to thing about continue refactoring of the for loop

m_tmp_operands.push(atof(token.c_str()));
}

Calculator::result Calculator::handleOperatorToken(const std::string &token)
Copy link
Contributor

Choose a reason for hiding this comment

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

do assertion in places where you need

return 0.0;
if (isOperator(token)) {
if (!handleOperatorToken(token)) {
return {};
Copy link
Contributor

Choose a reason for hiding this comment

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

In case if there is wrong input, user will see 0 as calculation result?

ASSERT_EQ(calculator.calculate("0 3 2 + /"), 0);
}

TEST_F(CalculatorTest, SimbolNotSuported) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not enough tests for negative test cases

continue;
}

m_error = "input simbol: " + token + " not supported!";
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest to extract token validation to separate loop and use calculation loop without error handling for this.

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.

3 participants