-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: master
Are you sure you want to change the base?
init calculator unit test #10
Conversation
TDD / extreame programing try
src/Calculator/calculator.cpp
Outdated
continue; | ||
} | ||
|
||
if (isOperator(token.at(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.
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) |
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.
do assertion in places where you need
return 0.0; | ||
if (isOperator(token)) { | ||
if (!handleOperatorToken(token)) { | ||
return {}; |
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.
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) { |
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.
Not enough tests for negative test cases
continue; | ||
} | ||
|
||
m_error = "input simbol: " + token + " not supported!"; |
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.
suggest to extract token validation to separate loop and use calculation loop without error handling for this.
TDD / extreame programing try