Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
M1 INFO FSI TP Template-MEDEDJI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MEDEDJI Setondji
M1 INFO FSI TP Template-MEDEDJI
Commits
d3693dd9
Commit
d3693dd9
authored
1 year ago
by
MEDEDJI Setondji
Browse files
Options
Downloads
Patches
Plain Diff
Question 6
parent
1a37a68d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
TP2/src/test/java/complex/ComplexTest.java
+34
-20
34 additions, 20 deletions
TP2/src/test/java/complex/ComplexTest.java
with
34 additions
and
20 deletions
TP2/src/test/java/complex/ComplexTest.java
+
34
−
20
View file @
d3693dd9
...
...
@@ -11,49 +11,61 @@ import org.junit.jupiter.api.BeforeEach;
import
org.junit.jupiter.api.Disabled
;
import
org.junit.jupiter.api.Test
;
import
java.sql.SQLOutput
;
/**
* Test class for the complex class.
*/
class
ComplexTest
{
private
Complex
z
;
private
Complex
z1
;
private
Complex
z2
;
private
static
final
float
EPSILON
=
0.000001
F
;
@BeforeAll
static
void
setUpBeforeClass
()
throws
Exception
{
// TODO: add message
System
.
out
.
println
(
"La méthode setUpBeforeClass est bien exécutée avant les tests "
);
}
@AfterAll
static
void
tearDownAfterClass
()
throws
Exception
{
// TODO: add message
System
.
out
.
println
(
"La méthode tearDownAfterClass est bien exécutée après les tests"
);
}
@BeforeEach
void
setUp
()
throws
Exception
{
// TODO: add message
System
.
out
.
println
(
"setUp effectué avant chaque test"
);
this
.
z
=
new
Complex
(
1.0
F
,
2.0f
);
this
.
z1
=
new
Complex
(
1.0
F
,
2.0
F
);
this
.
z2
=
new
Complex
(
3.0
F
,
4.0
F
);
}
@AfterEach
void
tearDown
()
throws
Exception
{
// TODO: add message
// TODO: add messageDisabled
System
.
out
.
println
(
"tearDown effectué apres chaque test"
);
}
@Test
void
testGetterImaginary
()
{
System
.
out
.
println
(
"1er test"
);
float
expected
=
2.0
F
;
Complex
z
=
new
Complex
(
1.0
F
,
2.0f
);
assertThat
(
z
.
getImaginaryPart
()).
as
(
"problem on getter imaginary"
)
.
isCloseTo
(
expected
,
within
(
EPSILON
));
}
@Test
void
testGetterReal
()
{
float
expected
=
1.0
F
;
Complex
z
=
new
Complex
(
1.0
F
,
2.0f
);
assertThat
(
z
.
getRealPart
()).
as
(
"problem on getter real"
)
.
isCloseTo
(
expected
,
within
(
EPSILON
));
...
...
@@ -64,7 +76,6 @@ class ComplexTest {
void
testSetterImaginary
()
{
float
expected
=
3.0
F
;
Complex
z
=
new
Complex
();
z
.
setImaginaryPart
(
expected
);
assertThat
(
z
.
getImaginaryPart
()).
as
(
"problem on setter imaginary"
)
.
isCloseTo
(
expected
,
within
(
EPSILON
));
...
...
@@ -76,7 +87,6 @@ class ComplexTest {
void
testSetterReal
()
{
float
expected
=
3.0
F
;
Complex
z
=
new
Complex
();
z
.
setRealPart
(
expected
);
assertThat
(
z
.
getRealPart
()).
as
(
"problem on setter real"
)
.
isCloseTo
(
expected
,
within
(
EPSILON
));
...
...
@@ -84,22 +94,18 @@ class ComplexTest {
@Test
void
testZeroTrue
()
{
Complex
z
=
new
Complex
(
0.0
F
,
0.0
F
);
assertThat
(
z
.
isZero
()).
as
(
"problem with isZero on Zero Complex number"
)
assertThat
(!
z
.
isZero
()).
as
(
"problem with isZero on Zero Complex number"
)
.
isTrue
();
}
@Test
void
testZeroFalse
()
{
Complex
z
=
new
Complex
(
1.0
F
,
1.0
F
);
assertThat
(
z
.
isZero
()).
as
(
"problem with isZero on non Zero Complex number"
)
.
isFalse
();
}
@Test
void
testSumReal
()
{
Complex
z1
=
new
Complex
(
1.0
F
,
2.0
F
);
Complex
z2
=
new
Complex
(
3.0
F
,
4.0
F
);
float
expected
=
1.0
F
+
3.0
F
;
...
...
@@ -110,20 +116,17 @@ class ComplexTest {
@Test
void
testSumImaginary
()
{
Complex
z1
=
new
Complex
(
1.0
F
,
2.0
F
);
Complex
z2
=
new
Complex
(
3.0
F
,
4.0
F
);
float
expected
=
2.0
F
+
4.0
F
;
Complex
z
=
z1
.
sum
(
z2
);
assertThat
(
z
.
getImaginaryPart
()).
as
(
"problem with imaginary part of Sum"
)
.
isCloseTo
(
expected
,
within
(
EPSILON
));
System
.
out
.
println
(
"Dernier test"
);
}
@Disabled
@Test
void
testProductReal
()
{
Complex
z1
=
new
Complex
(
1.0
F
,
2.0
F
);
Complex
z2
=
new
Complex
(
3.0
F
,
4.0
F
);
float
expected
=
1.0
F
*
3.0
F
-
2.0
F
*
4.0
F
;
...
...
@@ -132,24 +135,35 @@ class ComplexTest {
.
isCloseTo
(
expected
,
within
(
EPSILON
));
}
@Disabled
@Test
void
testProductImaginary
()
{
Complex
z1
=
new
Complex
(
1.0
F
,
2.0
F
);
Complex
z2
=
new
Complex
(
3.0
F
,
4.0
F
);
float
expected
=
1.0
F
*
4.0
F
+
2.0
F
*
3.0
F
;
Complex
z
=
z1
.
product
(
z2
);
z1
.
product
(
z2
);
assertThat
(
z
.
getImaginaryPart
()).
as
(
"problem with imaginary part of Product"
)
.
isCloseTo
(
expected
,
within
(
EPSILON
));
}
@Disabled
@Test
final
void
testTimeoutInfinite
()
{
Complex
.
infinite
();
fail
(
"NYI"
);
}
@Test
void
testIsRealPartOfInverseIsCorrect
(){
}
@Test
void
testIsImaginaryPartOfInverseIsCorrect
(){
}
}
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