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
Feb 27, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrote PositionTest
parent
450db60e
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
;
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
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
...
@@ -14,62 +9,31 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
...
@@ -14,62 +9,31 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*/
*/
class
PositionTest
{
class
PositionTest
{
private
Board
board
;
private
Position
position
;
@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
());
}
@Test
@Test
void
create
()
{
void
create
FromString
()
{
Position
position
=
Position
.
create
(
"b4"
);
position
=
Position
.
create
(
"b4"
);
assertEquals
(
'b'
,
position
.
getColumn
());
assertEquals
(
'b'
,
position
.
getColumn
());
assertEquals
(
1
,
position
.
getIntColumn
());
assertEquals
(
1
,
position
.
getIntColumn
());
assertEquals
(
'4'
,
position
.
getCharRow
());
assertEquals
(
'4'
,
position
.
getCharRow
());
assertEquals
(
3
,
position
.
getRow
());
assertEquals
(
3
,
position
.
getRow
());
}
}
// TODO: 2/26/2019 finish the test methods
@Test
@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
@Test
void
toStringTest
()
{
void
toStringTest
()
{
}
position
=
Position
.
create
(
"b4"
);
assertEquals
(
"b4"
,
position
.
toString
());
@Test
position
=
Position
.
create
(
2
,
4
);
void
getRow
()
{
assertEquals
(
"e3"
,
position
.
toString
());
}
@Test
void
getColumn
()
{
}
@Test
void
getIntColumn
()
{
}
}
}
}
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