Created MyCalculator and MyCalculatorTest class. Test coverage 100%#285
Open
VladyslavLekhter wants to merge 4 commits into
Open
Created MyCalculator and MyCalculatorTest class. Test coverage 100%#285VladyslavLekhter wants to merge 4 commits into
VladyslavLekhter wants to merge 4 commits into
Conversation
Yelinskyi
suggested changes
Sep 13, 2021
| } | ||
| return firstNumber / secondNumber; | ||
| case RAISING_TO_A_POWER: | ||
| return Math.pow(firstNumber, secondNumber); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
What will be if values are 2.0 and 1.1?
Will the test be passed?
Yelinskyi
approved these changes
Sep 14, 2021
MaliukDaria
suggested changes
Sep 14, 2021
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 = '^'; |
There was a problem hiding this comment.
constants should be declare before non-constant fields
| } | ||
|
|
||
| @Test | ||
| void addition_PositiveNumbers_Ok() { |
There was a problem hiding this comment.
Let's name our methods based on the pattern <methodUnderTest>_<state>_<expectedBehavior>
MaliukDaria
approved these changes
Sep 14, 2021
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.