added calculator solution#286
Conversation
| return firstValue * secondValue; | ||
| } | ||
| case '/' : { | ||
| if (secondValue == 0) { |
There was a problem hiding this comment.
Division by zero is not always forbidden.
| assertEquals(expectedFirstZero, actualFirstZero); | ||
| assertEquals(expectedSecondZero, actualSecondZero); | ||
| assertEquals(expectedBothZero, actualBothZero); |
There was a problem hiding this comment.
Not sure that we should use few assertions in one test.
There was a problem hiding this comment.
As i can see multiple assertions are used in tests from previous homeworks, so I decided to use them too.
| void multiplyTwoMinNumbers_Ok() { | ||
| actual = calculatorService.calculate(Double.MIN_VALUE, Double.MIN_VALUE, '-'); | ||
| expected = 0; | ||
| assertEquals(expected, actual); | ||
| } |
There was a problem hiding this comment.
fixed, didn't notice it. Thank you.
| void raiseNegativeNumberToNegativePower_Ok() { | ||
| actual = calculatorService.calculate(-4, -2, '^'); | ||
| expected = 0.0625; | ||
| assertEquals(expected, actual); | ||
| } |
There was a problem hiding this comment.
Maybe we should use delta in such cases?
There was a problem hiding this comment.
Worked fine for me without delta, but added it anyway
| return firstValue * secondValue; | ||
| } | ||
| case '/' : { | ||
| if (firstValue != 0.0d && secondValue == 0) { |
There was a problem hiding this comment.
| if (firstValue != 0.0d && secondValue == 0) { | |
| if (firstValue != 0 && secondValue == 0) { |
| double actualBothZero = calculatorService.calculate(0, 0, '+'); | ||
| double expectedFirstZero = 5; | ||
| double expectedSecondZero = 50; | ||
| double expectedBothZero = 0; |
There was a problem hiding this comment.
you have expected variable. you can reassign value after each assertion
| void additionWithZero_Ok() { | ||
| double actualFirstZero = calculatorService.calculate(0, 5, '+'); | ||
| double actualSecondZero = calculatorService.calculate(50, 0, '+'); | ||
| double actualBothZero = calculatorService.calculate(0, 0, '+'); |
| } | ||
|
|
||
| @Test | ||
| void addTwoPositiveNumbers_Ok() { |
There was a problem hiding this comment.
what method co we test?
| actual = calculatorService.calculate(0, 0, '+'); | ||
| expected = 55; | ||
| assertNotEquals(expected, actual); |
There was a problem hiding this comment.
what is this test? how should it fail?
| @Test | ||
| void subtractTwoZeroNumbers_NotOk() { | ||
| actual = calculatorService.calculate(0, 0, '-'); | ||
| expected = 5555; | ||
| assertNotEquals(expected, actual); | ||
| } |
| } | ||
|
|
||
| @Test | ||
| void raisingNegativeToZeroPower_Ok() { |
There was a problem hiding this comment.
what about zeroToNegativePower?
No description provided.