Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wang tile template
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LABOUREL Arnaud
wang tile template
Commits
d921c4fb
Commit
d921c4fb
authored
3 years ago
by
LABOUREL Arnaud
Browse files
Options
Downloads
Patches
Plain Diff
Ajouts tests supplémentaires
parent
ba0648b8
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/java/ByteGrayColor.java
+7
-0
7 additions, 0 deletions
src/main/java/ByteGrayColor.java
src/test/java/ByteGrayColorTest.java
+34
-1
34 additions, 1 deletion
src/test/java/ByteGrayColorTest.java
src/test/java/MatrixGrayImageTest.java
+13
-2
13 additions, 2 deletions
src/test/java/MatrixGrayImageTest.java
with
54 additions
and
3 deletions
src/main/java/ByteGrayColor.java
+
7
−
0
View file @
d921c4fb
...
@@ -10,8 +10,15 @@ public class ByteGrayColor implements GrayColor {
...
@@ -10,8 +10,15 @@ public class ByteGrayColor implements GrayColor {
private
static
final
int
MAXIMUM_GRAY_LEVEL
=
255
;
private
static
final
int
MAXIMUM_GRAY_LEVEL
=
255
;
private
static
final
int
OPACITY
=
1
;
private
static
final
int
OPACITY
=
1
;
// TODO : rajouter constantes publique BLACK et WHITE
private
final
int
grayLevel
;
private
final
int
grayLevel
;
public
ByteGrayColor
(){
this
.
grayLevel
=
MINIMUM_GRAY_LEVEL
;
}
public
ByteGrayColor
(
int
grayLevel
)
{
public
ByteGrayColor
(
int
grayLevel
)
{
// TODO : Corriger l'initialisation de la propriété grayLevel de l'instance.
// TODO : Corriger l'initialisation de la propriété grayLevel de l'instance.
this
.
grayLevel
=
0
;
this
.
grayLevel
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/test/java/ByteGrayColorTest.java
+
34
−
1
View file @
d921c4fb
...
@@ -18,4 +18,37 @@ public class ByteGrayColorTest {
...
@@ -18,4 +18,37 @@ public class ByteGrayColorTest {
assertThat
(
color1
.
getLuminosity
()).
isCloseTo
(.
25
,
within
(.
01
));
assertThat
(
color1
.
getLuminosity
()).
isCloseTo
(.
25
,
within
(.
01
));
assertThat
(
color2
.
getLuminosity
()).
isCloseTo
(.
75
,
within
(.
01
));
assertThat
(
color2
.
getLuminosity
()).
isCloseTo
(.
75
,
within
(.
01
));
}
}
@Test
public
void
testCompareTo_whenColorsCreatedWithGrayLevel
(){
ByteGrayColor
color1
=
new
ByteGrayColor
(
100
);
ByteGrayColor
color2
=
new
ByteGrayColor
(
100
);
ByteGrayColor
color3
=
new
ByteGrayColor
(
150
);
assertThat
(
color1
.
compareTo
(
color3
)).
isNegative
();
assertThat
(
color3
.
compareTo
(
color1
)).
isPositive
();
assertThat
(
color1
.
compareTo
(
color3
)).
isEqualTo
(-(
color3
.
compareTo
(
color1
)));
assertThat
(
color1
.
compareTo
(
color2
)).
isZero
();
}
@Test
public
void
testCompareTo_whenColorsCreatedWithLuminosity
(){
ByteGrayColor
color1
=
new
ByteGrayColor
(
0.20
);
ByteGrayColor
color2
=
new
ByteGrayColor
(
0.20
);
ByteGrayColor
color3
=
new
ByteGrayColor
(
0.60
);
assertThat
(
color1
.
compareTo
(
color3
)).
isNegative
();
assertThat
(
color3
.
compareTo
(
color1
)).
isPositive
();
assertThat
(
color1
.
compareTo
(
color3
)).
isEqualTo
(-(
color3
.
compareTo
(
color1
)));
assertThat
(
color1
.
compareTo
(
color2
)).
isZero
();
}
@Test
public
void
testCompareTo_whenColorsCreatedWithLuminosityAndGrayLevel
(){
ByteGrayColor
color1
=
new
ByteGrayColor
(
0
.);
ByteGrayColor
color2
=
new
ByteGrayColor
(
0
);
ByteGrayColor
color3
=
new
ByteGrayColor
(
100
);
assertThat
(
color1
.
compareTo
(
color3
)).
isNegative
();
assertThat
(
color3
.
compareTo
(
color1
)).
isPositive
();
assertThat
(
color1
.
compareTo
(
color3
)).
isEqualTo
(-(
color3
.
compareTo
(
color1
)));
assertThat
(
color1
.
compareTo
(
color2
)).
isZero
();
}
}
}
This diff is collapsed.
Click to expand it.
src/test/java/MatrixGrayImageTest.java
+
13
−
2
View file @
d921c4fb
...
@@ -5,16 +5,27 @@ import static org.assertj.core.api.Assertions.*;
...
@@ -5,16 +5,27 @@ import static org.assertj.core.api.Assertions.*;
class
MatrixGrayImageTest
{
class
MatrixGrayImageTest
{
@Test
@Test
void
g
etWidth
()
{
void
testG
etWidth
()
{
assertThat
(
new
MatrixGrayImage
(
0
,
0
).
getWidth
()).
isEqualTo
(
0
);
assertThat
(
new
MatrixGrayImage
(
0
,
0
).
getWidth
()).
isEqualTo
(
0
);
assertThat
(
new
MatrixGrayImage
(
10
,
20
).
getWidth
()).
isEqualTo
(
10
);
assertThat
(
new
MatrixGrayImage
(
10
,
20
).
getWidth
()).
isEqualTo
(
10
);
assertThat
(
new
MatrixGrayImage
(
400
,
300
).
getWidth
()).
isEqualTo
(
400
);
assertThat
(
new
MatrixGrayImage
(
400
,
300
).
getWidth
()).
isEqualTo
(
400
);
}
}
@Test
@Test
void
g
etHeight
()
{
void
testG
etHeight
()
{
assertThat
(
new
MatrixGrayImage
(
0
,
0
).
getHeight
()).
isEqualTo
(
0
);
assertThat
(
new
MatrixGrayImage
(
0
,
0
).
getHeight
()).
isEqualTo
(
0
);
assertThat
(
new
MatrixGrayImage
(
10
,
20
).
getHeight
()).
isEqualTo
(
20
);
assertThat
(
new
MatrixGrayImage
(
10
,
20
).
getHeight
()).
isEqualTo
(
20
);
assertThat
(
new
MatrixGrayImage
(
400
,
300
).
getHeight
()).
isEqualTo
(
300
);
assertThat
(
new
MatrixGrayImage
(
400
,
300
).
getHeight
()).
isEqualTo
(
300
);
}
}
@Test
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