Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tutoria_Examples_T03
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mahboobe Shakeri
Tutoria_Examples_T03
Commits
9012d582
Commit
9012d582
authored
5 months ago
by
Mahboobe Shakeri
Browse files
Options
Downloads
Patches
Plain Diff
adding SquareRootTests
parent
34ae2e07
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/CalculatorTest.java
+24
-8
24 additions, 8 deletions
test/CalculatorTest.java
with
24 additions
and
8 deletions
test/CalculatorTest.java
+
24
−
8
View file @
9012d582
...
...
@@ -52,16 +52,32 @@ class CalculatorTest {
}
@Test
void
test
AddWithMaxValue
()
{
assertEquals
(
Integer
.
MAX_VALUE
,
calculator
.
add
(
Integer
.
MAX_VALUE
,
0
),
"Adding 0 to Integer.MAX_VALUE should return Integer.MAX_VALUE
"
);
assertEquals
(
Integer
.
MAX_VALUE
,
calculator
.
add
(
Integer
.
MAX_VALUE
,
1
),
"Adding 1 to Integer.MAX_VALUE should return Integer.MAX_VALUE"
);
void
test
SquareRootMethodWithPositiveNumber
()
{
assertEquals
(
2
,
calculator
.
squareRoot
(
4
),
"square root method should return 2
"
);
}
@Test
void
testSquareRootMethodWithZero
(){
assertEquals
(
0
,
calculator
.
squareRoot
(
0
),
"square root method should return 0"
);
}
@Test
void
testAddWithMaxValueException
()
{
Exception
exception
=
assertThrows
(
ArithmeticException
.
class
,
()
->
{
calculator
.
add
(
Integer
.
MAX_VALUE
,
Integer
.
MAX_VALUE
);
});
assertT
rue
(
exception
.
getMessage
().
contains
(
"integer overflow"
)
);
@Test
void
testSquareRootMethodWithNegativeNumber
(){
//
assertThrows(IllegalArgumentException.class, () -> {calculator.squareRoot(-2);
});
assertT
hrows
(
IllegalArgumentException
.
class
,
()
->{
calculator
.
squareRoot
(-
2
);}
);
}
// @Test
// void testAddWithMaxValue() {
// assertEquals(Integer.MAX_VALUE, calculator.add(Integer.MAX_VALUE, 0), "Adding 0 to Integer.MAX_VALUE should return Integer.MAX_VALUE");
// assertEquals(Integer.MAX_VALUE, calculator.add(Integer.MAX_VALUE, 1), "Adding 1 to Integer.MAX_VALUE should return Integer.MAX_VALUE");
//
// }
// @Test void testAddWithMaxValueException() {
// Exception exception = assertThrows(ArithmeticException.class, () -> {
// calculator.add(Integer.MAX_VALUE, Integer.MAX_VALUE);
// });
// assertTrue(exception.getMessage().contains("integer overflow"));
// }
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment