Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Image-Template
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
L3_InfoAMU
S3
Programmation 2
Image-Template
Commits
1efa5a33
Commit
1efa5a33
authored
3 years ago
by
LABOUREL Arnaud
Browse files
Options
Downloads
Patches
Plain Diff
Correction tests
parent
6915c369
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
build.gradle
+4
-4
4 additions, 4 deletions
build.gradle
src/test/java/ByteGrayColorTest.java
+44
-7
44 additions, 7 deletions
src/test/java/ByteGrayColorTest.java
src/test/java/MatrixGrayImageTest.java
+21
-12
21 additions, 12 deletions
src/test/java/MatrixGrayImageTest.java
with
69 additions
and
23 deletions
build.gradle
+
4
−
4
View file @
1efa5a33
...
...
@@ -13,9 +13,9 @@ repositories {
}
dependencies
{
testImplementation
(
'org.junit.jupiter:junit-jupiter-api:5.
7.2
'
,
'org.
hamcrest:hamcrest-library:2.2'
,
'net.obvj:junit-utils:1.3.1
'
)
testRuntimeOnly
'org.junit.jupiter:junit-jupiter-engine:5.
7.2'
testImplementation
(
'org.junit.jupiter:junit-jupiter-api:5.
8.1
'
,
'org.
assertj:assertj-core:3.21.0
'
)
testRuntimeOnly
(
'org.junit.jupiter:junit-jupiter-engine:5.
8.1'
)
}
test
{
...
...
@@ -24,4 +24,4 @@ test {
application
{
mainClassName
=
"Main"
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
src/test/java/ByteGrayColorTest.java
+
44
−
7
View file @
1efa5a33
import
org.junit.jupiter.api.Test
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
closeTo
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.*;
public
class
ByteGrayColorTest
{
@Test
public
void
testGetLuminosity_whenColorCreatedWithGrayLevel
(){
ByteGrayColor
black
=
new
ByteGrayColor
(
0
);
ByteGrayColor
white
=
new
ByteGrayColor
(
255
);
assertThat
(
black
.
getLuminosity
()
,
is
(
c
loseTo
(
0
.,
.
0001
)
));
assertThat
(
white
.
getLuminosity
()
,
is
(
c
loseTo
(
1
.,
.
0001
)
));
assertThat
(
black
.
getLuminosity
()
).
isC
loseTo
(
0
.,
within
(.
01
));
assertThat
(
white
.
getLuminosity
()
).
isC
loseTo
(
1
.,
within
(.
01
));
}
@Test
public
void
testGetLuminosity_whenColorCreatedWithLuminosity
(){
ByteGrayColor
color1
=
new
ByteGrayColor
(.
25
);
ByteGrayColor
color2
=
new
ByteGrayColor
(.
75
);
assertThat
(
color1
.
getLuminosity
(),
is
(
closeTo
(.
25
,.
01
)));
assertThat
(
color2
.
getLuminosity
(),
is
(
closeTo
(.
75
,.
01
)));
assertThat
(
color1
.
getLuminosity
()).
isCloseTo
(.
25
,
within
(.
01
));
assertThat
(
color2
.
getLuminosity
()).
isCloseTo
(.
75
,
within
(.
01
));
}
@Test
public
void
testCompareTo_whenColorsCreatedWithGrayLevel
(){
ByteGrayColor
color1
=
new
ByteGrayColor
(
100
);
ByteGrayColor
color2
=
new
ByteGrayColor
(
150
);
ByteGrayColor
color3
=
new
ByteGrayColor
(
200
);
ByteGrayColor
sameGrayLevelAsColor1
=
new
ByteGrayColor
(
100
);
assertThat
(
color1
.
compareTo
(
color2
)).
isNegative
();
assertThat
(
color2
.
compareTo
(
color3
)).
isNegative
();
assertThat
(
color1
.
compareTo
(
color3
)).
isNegative
();
assertThat
(
color2
.
compareTo
(
color1
)).
isPositive
();
assertThat
(
color1
.
compareTo
(
sameGrayLevelAsColor1
)).
isZero
();
assertThat
(
color1
.
compareTo
(
color2
)).
isEqualTo
(
sameGrayLevelAsColor1
.
compareTo
(
color2
));
}
@Test
public
void
testCompareTo_whenColorsCreatedWithLuminosity
(){
ByteGrayColor
color1
=
new
ByteGrayColor
(
0.20
);
ByteGrayColor
color2
=
new
ByteGrayColor
(
0.60
);
ByteGrayColor
color3
=
new
ByteGrayColor
(
0.80
);
ByteGrayColor
sameLuminosityAsColor1
=
new
ByteGrayColor
(
0.20
);
assertThat
(
color1
.
compareTo
(
color2
)).
isNegative
();
assertThat
(
color2
.
compareTo
(
color3
)).
isNegative
();
assertThat
(
color1
.
compareTo
(
color3
)).
isNegative
();
assertThat
(
color2
.
compareTo
(
color1
)).
isPositive
();
assertThat
(
color1
.
compareTo
(
sameLuminosityAsColor1
)).
isZero
();
assertThat
(
color1
.
compareTo
(
color2
)).
isEqualTo
(
sameLuminosityAsColor1
.
compareTo
(
color2
));
}
@Test
public
void
testCompareTo_whenColorsCreatedWithLuminosityAndGrayLevel
(){
ByteGrayColor
color1
=
new
ByteGrayColor
(
0
.);
ByteGrayColor
color2
=
new
ByteGrayColor
(
150
);
ByteGrayColor
color3
=
new
ByteGrayColor
(
1
.);
assertThat
(
color1
.
compareTo
(
color2
)).
isNegative
();
assertThat
(
color2
.
compareTo
(
color3
)).
isNegative
();
assertThat
(
color1
.
compareTo
(
color3
)).
isNegative
();
assertThat
(
color2
.
compareTo
(
color1
)).
isPositive
();
}
}
This diff is collapsed.
Click to expand it.
src/test/java/MatrixGrayImageTest.java
+
21
−
12
View file @
1efa5a33
import
org.junit.jupiter.api.Test
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.*;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
class
MatrixGrayImageTest
{
@Test
void
getWidth
()
{
assertThat
(
new
MatrixGrayImage
(
0
,
0
).
getWidth
(),
is
(
equalTo
(
0
)));
assertThat
(
new
MatrixGrayImage
(
10
,
20
).
getWidth
(),
is
(
equalTo
(
10
)));
assertThat
(
new
MatrixGrayImage
(
400
,
300
).
getWidth
(),
is
(
equalTo
(
400
)));
void
testGetWidth
()
{
assertThat
(
new
MatrixGrayImage
(
0
,
0
).
getWidth
()).
isEqualTo
(
0
);
assertThat
(
new
MatrixGrayImage
(
10
,
20
).
getWidth
()).
isEqualTo
(
10
);
assertThat
(
new
MatrixGrayImage
(
400
,
300
).
getWidth
()).
isEqualTo
(
400
);
}
@Test
void
testGetHeight
()
{
assertThat
(
new
MatrixGrayImage
(
0
,
0
).
getHeight
()).
isEqualTo
(
0
);
assertThat
(
new
MatrixGrayImage
(
10
,
20
).
getHeight
()).
isEqualTo
(
20
);
assertThat
(
new
MatrixGrayImage
(
400
,
300
).
getHeight
()).
isEqualTo
(
300
);
}
@Test
void
getHeight
()
{
assertThat
(
new
MatrixGrayImage
(
0
,
0
).
getHeight
(),
is
(
equalTo
(
0
)));
assertThat
(
new
MatrixGrayImage
(
10
,
20
).
getHeight
(),
is
(
equalTo
(
20
)));
assertThat
(
new
MatrixGrayImage
(
400
,
300
).
getHeight
(),
is
(
equalTo
(
300
)));
void
testGetPixel_whenPixelHasBeenSet
()
{
GrayColor
grey1
=
new
ByteGrayColor
(
0.2
);
GrayColor
grey2
=
new
ByteGrayColor
(
0.8
);
MatrixGrayImage
image
=
new
MatrixGrayImage
(
10
,
10
);
image
.
setPixel
(
grey1
,
1
,
1
);
assertThat
(
image
.
getPixelGrayColor
(
1
,
1
)).
isEqualTo
(
grey1
);
image
.
setPixel
(
grey2
,
3
,
9
);
assertThat
(
image
.
getPixelGrayColor
(
3
,
9
)).
isEqualTo
(
grey2
);
}
}
\ 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