Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
agile-java
/
Chess
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ec7d9442
authored
6 years ago
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrote PositionTest
parent
450db60e
master
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
49 deletions
src/test/com/paktalin/chess/PositionTest.java
src/test/com/paktalin/chess/PositionTest.java
View file @
ec7d9442
package
com
.
paktalin
.
chess
;
import
com.paktalin.chess.pieces.Bishop
;
import
com.paktalin.chess.pieces.Pawn
;
import
com.paktalin.chess.pieces.Piece
;
import
javafx.geometry.Pos
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
...
...
@@ -14,62 +9,31 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*/
class
PositionTest
{
private
Board
board
;
@BeforeEach
void
init
()
{
board
=
Board
.
createEmpty
();
}
@Test
void
testCreate
()
{
Position
position
=
Position
.
create
(
"a8"
);
assertEquals
(
"a8"
,
position
.
toString
());
assertEquals
(
0
,
position
.
getIntColumn
());
assertEquals
(
7
,
position
.
getRow
());
}
@Test
void
testStrengthByPosition
()
{
verifyStrength
(
new
Bishop
(
Color
.
Black
),
"b5"
,
3.0
);
verifyStrength
(
new
Pawn
(
Color
.
White
),
"a2"
,
1.0
);
verifyStrength
(
new
Pawn
(
Color
.
White
),
"a3"
,
0.5
);
assertEquals
(
0.5
,
board
.
getPieceAtPosition
(
"a2"
).
getStrength
());
}
private
void
verifyStrength
(
Piece
piece
,
String
position
,
double
strength
)
{
board
.
placePiece
(
piece
,
position
);
piece
=
board
.
getPieceAtPosition
(
position
);
assertEquals
(
strength
,
piece
.
getStrength
());
}
private
Position
position
;
@Test
void
create
()
{
Position
position
=
Position
.
create
(
"b4"
);
void
create
FromString
()
{
position
=
Position
.
create
(
"b4"
);
assertEquals
(
'b'
,
position
.
getColumn
());
assertEquals
(
1
,
position
.
getIntColumn
());
assertEquals
(
'4'
,
position
.
getCharRow
());
assertEquals
(
3
,
position
.
getRow
());
}
// TODO: 2/26/2019 finish the test methods
@Test
void
create1
()
{
void
createFromInts
()
{
position
=
Position
.
create
(
1
,
2
);
assertEquals
(
1
,
position
.
getRow
());
assertEquals
(
'2'
,
position
.
getCharRow
());
assertEquals
(
'c'
,
position
.
getColumn
());
assertEquals
(
2
,
position
.
getIntColumn
());
}
@Test
void
toStringTest
()
{
}
@Test
void
getRow
()
{
}
@Test
void
getColumn
()
{
}
@Test
void
getIntColumn
()
{
position
=
Position
.
create
(
"b4"
);
assertEquals
(
"b4"
,
position
.
toString
());
position
=
Position
.
create
(
2
,
4
);
assertEquals
(
"e3"
,
position
.
toString
());
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment