Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LO21_Pin_Noir_Boucher_Bouri_Detree
CellulutLO21
Commits
f98e7f03
Commit
f98e7f03
authored
Apr 21, 2021
by
Yann Boucher
Browse files
Implemented equality/inequality operators for Coord, fixing
#25
parent
da469475
Pipeline
#76821
passed with stages
in 18 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/coord.hpp
View file @
f98e7f03
...
...
@@ -23,4 +23,16 @@ struct Coord
int
x
,
y
;
};
//! \brief Teste si deux coordonnées sont égales (même 'x' et 'y')
inline
bool
operator
==
(
const
Coord
&
lhs
,
const
Coord
&
rhs
)
{
return
lhs
.
x
==
rhs
.
x
&&
lhs
.
y
==
rhs
.
y
;
}
//! \brief Teste si deux coordonnées sont différentes
inline
bool
operator
!=
(
const
Coord
&
lhs
,
const
Coord
&
rhs
)
{
return
!
(
lhs
==
rhs
);
}
#endif // COORD_HPP
include/factory.hpp
View file @
f98e7f03
...
...
@@ -33,7 +33,7 @@ public:
//! \brief Retourne un objet créé à partir de choice
//!
//! Fabrique un objet du type représenté par choice.
//! \param choice Le nom de la classe à fabriqu
é
, tel que présent dans la liste retournée par list_choices().
//! \param choice Le nom de la classe à fabriqu
er
, tel que présent dans la liste retournée par list_choices().
//! \return Un unique_pointer de type Base pointant vers l'objet construit, ou nullptr si choice est invalide.
static
std
::
unique_ptr
<
Base
>
make
(
const
std
::
string
&
choice
)
{
...
...
include/neighborhood.hpp
View file @
f98e7f03
...
...
@@ -15,9 +15,10 @@ Cette classe représente le voisinage d'une cellule.
#include
<vector>
#include
<utility>
#include
"coord.hpp"
using
namespace
std
;
class
Coord
;
class
State
;
class
Neighborhood
{
...
...
@@ -27,7 +28,7 @@ class Neighborhood {
//! \brief Fonction vérifiant que la coordonnée d'un voisin que l'on souhaite ajouter dans le vecteur neighborPositions est unique
//! \param Coord : Coordonnée à comparer
//! \return retourne vrai si la coordonnée est unique sinon faux s'il existe un doublon
bool
Neighborhood
::
isUnique
(
const
Coord
c
)
const
;
bool
isUnique
(
const
Coord
c
)
const
;
public:
//! \brief Retourne le nombre de voisin ayant l'état définit en paramètre
//! \param State : Etat des voisins à rechercher
...
...
@@ -48,4 +49,4 @@ public:
};
#endif // NEIGHBOURHOOD_HPP
\ No newline at end of file
#endif // NEIGHBOURHOOD_HPP
tests/cellulut_tests.hpp
View file @
f98e7f03
...
...
@@ -11,6 +11,7 @@ private slots:
void
test_loader_saver_visitor
();
void
test_structure
();
void
test_factory
();
void
test_coord
();
};
#endif // CELLULUT_TESTS_HPP
tests/coord_tests.cpp
0 → 100644
View file @
f98e7f03
#include
<QtTest/QtTest>
#include
<algorithm>
#include
"cellulut_tests.hpp"
#include
"coord.hpp"
void
CellulutTests
::
test_coord
()
{
Coord
a
{
1
,
2
};
Coord
b
{
3
,
4
};
QCOMPARE
(
a
.
x
,
1
);
QCOMPARE
(
a
.
y
,
2
);
QVERIFY
(
a
==
a
);
QVERIFY
(
b
==
b
);
QVERIFY
(
a
!=
b
);
QVERIFY
(
!
(
a
==
b
));
}
tests/tests.pro
View file @
f98e7f03
...
...
@@ -15,6 +15,7 @@ INCLUDEPATH += ../include
SOURCES
+=
\
..
/
src
/
propertyvisitors
.
cpp
\
coord_tests
.
cpp
\
factory_tests
.
cpp
\
property_test
.
cpp
\
propertyvisitors_test
.
cpp
\
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment