implemented method Calculate and created tests#303
Open
mykolaskrypka wants to merge 2 commits into
Open
Conversation
RomanDubovskyi
suggested changes
Oct 18, 2021
Comment on lines
+225
to
+228
| void illegal_operation() { | ||
| try { | ||
| calculator.calculate(posA, posB, '?'); | ||
| } catch (IllegalOperationException e) { |
Contributor
There was a problem hiding this comment.
Suggested change
| void illegal_operation() { | |
| try { | |
| calculator.calculate(posA, posB, '?'); | |
| } catch (IllegalOperationException e) { | |
| void illegal_operation() { | |
| char illegalOperation = '?' | |
| try { | |
| calculator.calculate(posA, posB, illegalOperation); | |
| } catch (IllegalOperationException e) { |
для кращої читаймості неочевидні речі краще в неймінгу вказувати
| @@ -0,0 +1,7 @@ | |||
| package exceptions; | |||
|
|
|||
| public class IllegalOperationException extends Exception { | |||
Contributor
There was a problem hiding this comment.
тут краще unchecked ексепшин робити, нам нема сенсу змушувати юзера всюди покривати виклики в трай кетч
| @Test | ||
| void power_negative() throws IllegalOperationException { | ||
| double expected = Math.pow(negA, negB); | ||
| Double actual = calculator.calculate(negA, negB, '^'); |
Contributor
There was a problem hiding this comment.
чому тут Double обгортка?
| void adition_positive() throws IllegalOperationException { | ||
| double expected = posA + posB; | ||
| Double actual = calculator.calculate(posA, posB, '+'); | ||
| Assertions.assertEquals(expected, actual); |
Contributor
There was a problem hiding this comment.
при порівняння чисел з плаваючою точкою краще дельту використовувати, наприклад
...equals(expected, actual, 0.0001) щоб задавати точність
RomanDubovskyi
approved these changes
Oct 19, 2021
| private final double zero = 0; | ||
| private final double minDouble = Double.MIN_VALUE; | ||
| private final double maxDouble = Double.MAX_VALUE; | ||
| private final double accuracy = 0.0001; |
Contributor
There was a problem hiding this comment.
Suggested change
| private final double accuracy = 0.0001; | |
| private static final double DELTA = 0.0001; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.