Nantes Université
Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
É
Échecs féeriques
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de conteneur
Registre de modèles
Opération
Environnements
Surveillance
Incidents
Service d'assistance
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Evan JOUBERT
Échecs féeriques
Validations
ddce19c8
Valider
ddce19c8
rédigé
il y a 5 ans
par
Evan JOUBERT
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
test validation mouvement
parent
50434d63
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
src/test/ts/king-move-validation.spec.ts
+74
-3
74 ajouts, 3 suppressions
src/test/ts/king-move-validation.spec.ts
src/test/ts/queen-move-validation.spec.ts
+41
-2
41 ajouts, 2 suppressions
src/test/ts/queen-move-validation.spec.ts
avec
115 ajouts
et
5 suppressions
src/test/ts/king-move-validation.spec.ts
+
74
−
3
Voir le fichier @
ddce19c8
import
{
Expect
,
Test
,
Setup
}
from
"
alsatian
"
;
import
{
Chessboard
,
createEmptyChessboard
,
putPiece
}
from
'
../../main/ts/chessboard
'
;
import
{
Position
,
position
}
from
'
../../main/ts/position
'
;
import
*
as
isPossible
from
'
../../main/ts/move-validation
'
;
import
*
as
pieces
from
'
../../main/ts/piece
'
;
import
{
Move
,
move
}
from
'
../../main/ts/movements
'
;
let
chessboard
:
Chessboard
;
const
positionC2
:
Position
=
position
(
2
,
1
);
// C2
const
positionC3
:
Position
=
position
(
2
,
2
);
// C3
const
positionC4
:
Position
=
position
(
2
,
3
);
// C4
const
positionC6
:
Position
=
position
(
2
,
5
);
// C6
const
positionD3
:
Position
=
position
(
3
,
2
);
// D3
const
positionD4
:
Position
=
position
(
3
,
3
);
// D4
const
positionD5
:
Position
=
position
(
3
,
4
);
// D5
const
positionE2
:
Position
=
position
(
4
,
1
);
// E2
const
positionE3
:
Position
=
position
(
4
,
2
);
// E3
const
positionE4
:
Position
=
position
(
4
,
3
);
// E4
const
positionE5
:
Position
=
position
(
4
,
4
);
// E5
const
positionE6
:
Position
=
position
(
4
,
5
);
// E6
const
positionF3
:
Position
=
position
(
5
,
2
);
// F3
const
positionF4
:
Position
=
position
(
5
,
3
);
// F4
const
positionF5
:
Position
=
position
(
5
,
4
);
// F5
const
positionG2
:
Position
=
position
(
6
,
1
);
// G2
const
positionG4
:
Position
=
position
(
6
,
3
);
// G4
const
positionG6
:
Position
=
position
(
6
,
5
);
// G6
const
moveE4_D4
:
Move
=
move
(
positionE4
,
positionD4
);
const
moveE4_D5
:
Move
=
move
(
positionE4
,
positionD5
);
const
moveE4_E3
:
Move
=
move
(
positionE4
,
positionE3
);
const
moveE4_E5
:
Move
=
move
(
positionE4
,
positionE5
);
const
moveE4_F3
:
Move
=
move
(
positionE4
,
positionF3
);
const
moveE4_F4
:
Move
=
move
(
positionE4
,
positionF4
);
const
moveE4_F5
:
Move
=
move
(
positionE4
,
positionF5
);
const
moveE4_D3
:
Move
=
move
(
positionE4
,
positionD3
);
const
moveE4_C2
:
Move
=
move
(
positionE4
,
positionC2
);
const
moveE4_C3
:
Move
=
move
(
positionE4
,
positionC3
);
const
moveE4_C4
:
Move
=
move
(
positionE4
,
positionC4
);
const
moveE4_C6
:
Move
=
move
(
positionE4
,
positionC6
);
const
moveE4_E2
:
Move
=
move
(
positionE4
,
positionE2
);
const
moveE4_E6
:
Move
=
move
(
positionE4
,
positionE6
);
const
moveE4_G2
:
Move
=
move
(
positionE4
,
positionG2
);
const
moveE4_G4
:
Move
=
move
(
positionE4
,
positionG4
);
const
moveE4_G6
:
Move
=
move
(
positionE4
,
positionG6
);
export
class
TestKingMoves
{
@
Setup
...
...
@@ -10,19 +55,39 @@ export class TestKingMoves {
// TODO:
// Initialize an empty chessboard
// Place a black King on E4
chessboard
=
createEmptyChessboard
();
putPiece
(
chessboard
,
positionE4
,
pieces
.
blackKing
);
}
@
Test
(
"
A King can move 1 square in all directions
"
)
testCanMoveOneSquare
()
{
// TODO:
// Check it can move to squares D3, D4, D5, E3, E5, F3, F4, and F5
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_D4
)).
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_D5
)).
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_E3
)).
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_E5
)).
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_F3
)).
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_F4
)).
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_F5
)).
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_D3
)).
toBeTruthy
();
}
@
Test
(
"
A King cannot move more than 1 square
"
)
testCannotMoveMoreThanOneSquare
()
{
// TODO:
// Check it cannot move to squares C2, C3, C4, C6, E2, E6, G2, G4, and G6
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_C2
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_C3
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_C4
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_C6
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_E2
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_E6
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_G2
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_G4
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_G6
)).
not
.
toBeTruthy
();
}
@
Test
(
"
A King cannot capure pieces from the same color
"
)
...
...
@@ -30,6 +95,9 @@ export class TestKingMoves {
// TODO:
// Place a black Pawn on E5
// Check the King cannot move to E5.
putPiece
(
chessboard
,
positionE5
,
pieces
.
blackPawn
);
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_E5
)).
not
.
toBeTruthy
();
}
@
Test
(
"
A King can capure pieces from a different color
"
)
...
...
@@ -37,5 +105,8 @@ export class TestKingMoves {
// TODO:
// Place a white Pawn on E5
// Check the King can move to E5.
putPiece
(
chessboard
,
positionE5
,
pieces
.
whitePawn
);
Expect
(
isPossible
.
kingMove
(
chessboard
,
moveE4_E5
)).
toBeTruthy
();
}
}
\ No newline at end of file
}
This diff is collapsed.
Cliquez pour l'agrandir.
src/test/ts/queen-move-validation.spec.ts
+
41
−
2
Voir le fichier @
ddce19c8
import
{
Expect
,
Test
,
Setup
}
from
"
alsatian
"
;
import
{
Chessboard
,
createEmptyChessboard
,
putPiece
}
from
'
../../main/ts/chessboard
'
;
import
{
Position
,
position
}
from
'
../../main/ts/position
'
;
import
*
as
isPossible
from
'
../../main/ts/move-validation
'
;
import
*
as
pieces
from
'
../../main/ts/piece
'
;
import
{
Move
,
move
}
from
'
../../main/ts/movements
'
;
let
chessboard
:
Chessboard
;
const
positionA4
:
Position
=
position
(
0
,
3
)
// A4
const
positionE1
:
Position
=
position
(
4
,
0
)
// E1
const
positionE4
:
Position
=
position
(
4
,
3
)
// E4
const
positionE8
:
Position
=
position
(
4
,
7
)
// E8
const
positionF4
:
Position
=
position
(
5
,
3
);
//F4
const
positionH4
:
Position
=
position
(
7
,
3
)
// H4
const
moveE4_A4
:
Move
=
move
(
positionE4
,
positionA4
);
const
moveE4_H4
:
Move
=
move
(
positionE4
,
positionH4
);
const
moveE4_E1
:
Move
=
move
(
positionE4
,
positionE1
);
const
moveE4_E8
:
Move
=
move
(
positionE4
,
positionE8
);
const
moveE4_F4
:
Move
=
move
(
positionE4
,
positionF4
);
export
class
TestQueenMoves
{
@
Setup
...
...
@@ -9,6 +31,9 @@ export class TestQueenMoves {
// TODO:
// Initialize an empty chessboard
// Place a white Queen on E4
chessboard
=
createEmptyChessboard
();
putPiece
(
chessboard
,
positionE4
,
pieces
.
whiteQueen
);
}
@
Test
(
"
A Queen can move diagonally
"
)
...
...
@@ -22,12 +47,16 @@ export class TestQueenMoves {
testCanMoveHorizontally
()
{
// TODO:
// Check the following moves are possible: moveE4_H4, moveE4_A4
Expect
(
isPossible
.
queenMove
(
chessboard
,
moveE4_H4
)).
toBeTruthy
();
Expect
(
isPossible
.
queenMove
(
chessboard
,
moveE4_A4
)).
toBeTruthy
();
}
@
Test
(
"
A Queen can move vertically
"
)
testCanMoveVertically
()
{
// TODO:
// Check the following moves are possible: moveE4_E1, moveE4_E8
Expect
(
isPossible
.
queenMove
(
chessboard
,
moveE4_E8
)).
toBeTruthy
();
Expect
(
isPossible
.
queenMove
(
chessboard
,
moveE4_E1
)).
toBeTruthy
();
}
@
Test
(
"
A Queen can only move horizontally, vertically, and diagonally
"
)
...
...
@@ -41,19 +70,29 @@ export class TestQueenMoves {
// TODO:
// Place a white Pawn on C6 and a black Pawn on F4
// Check the moves moveE4_A8 and moveE4_H4 are impossible
putPiece
(
chessboard
,
positionF4
,
pieces
.
blackPawn
);
Expect
(
isPossible
.
queenMove
(
chessboard
,
moveE4_H4
)).
not
.
toBeTruthy
();
}
@
Test
(
"
A Queen cannot capure pieces from the same color
"
)
testCannotCaptureSameColor
()
{
// TODO:
// Place a white Pawn on H4
// Check the move moveE4_H4 is impossible
// Check the moveS moveE4_H4 is impossible
putPiece
(
chessboard
,
positionH4
,
pieces
.
whitePawn
);
Expect
(
isPossible
.
queenMove
(
chessboard
,
moveE4_H4
)).
not
.
toBeTruthy
();
}
@
Test
(
"
A Queen can capure pieces from a different color
"
)
testCanCaptureDifferentColor
()
{
// TODO:
// Place a black Pawn on H4
// Check the move moveE4_H4 is possible
// Check the move moveE4_H4 is possible
putPiece
(
chessboard
,
positionH4
,
pieces
.
blackPawn
);
Expect
(
isPossible
.
queenMove
(
chessboard
,
moveE4_H4
)).
toBeTruthy
();
}
}
\ No newline at end of file
This diff is collapsed.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter