Skip to content

Created MyCalculator and MyCalculatorTest class. Test coverage 100%#285

Open
VladyslavLekhter wants to merge 4 commits into
mate-academy:masterfrom
VladyslavLekhter:hw-lambda_calculator
Open

Created MyCalculator and MyCalculatorTest class. Test coverage 100%#285
VladyslavLekhter wants to merge 4 commits into
mate-academy:masterfrom
VladyslavLekhter:hw-lambda_calculator

Conversation

@VladyslavLekhter
Copy link
Copy Markdown

No description provided.

}
return firstNumber / secondNumber;
case RAISING_TO_A_POWER:
return Math.pow(firstNumber, secondNumber);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What can be if the result will be more than max value?
Will you receive a correct value?
Maybe you should throw an Exception?

@Test
void addition_PositiveNumbers_Ok() {
expected = 155.5;
actual = myCalculatorTest.calculate(90.5, '+', 65.0);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can + as constant and other sign too, you you did in MyCalculator class.

void addition_PositiveAndNegativeNumbers_Ok() {
expected = 136.5;
actual = myCalculatorTest.calculate(200.0, '+', -63.5);
assertEquals(expected, actual);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What will be if values are 2.0 and 1.1?
Will the test be passed?

Comment on lines +12 to +18
private static Calculator myCalculatorTest;
private static final double DELTA = 0.00001;
private static final char ADDITION = '+';
private static final char SUBTRACTION = '-';
private static final char MULTIPLICATION = '*';
private static final char DIVISION = '/';
private static final char RAISING_TO_A_POWER = '^';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

constants should be declare before non-constant fields

}

@Test
void addition_PositiveNumbers_Ok() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's name our methods based on the pattern <methodUnderTest>_<state>_<expectedBehavior>

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