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
f60086b4
Commit
f60086b4
authored
Apr 21, 2021
by
Yann Boucher
Browse files
Fixed issues in the Factory code and tests
parent
4c465de5
Pipeline
#76823
passed with stages
in 16 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/factory.hpp
View file @
f60086b4
...
...
@@ -17,6 +17,12 @@ Fichier contenant la class singleton template Factory, à qui on peut associer d
#include
<vector>
#include
<type_traits>
namespace
detail
{
template
<
typename
_Base
,
typename
Child
>
bool
register_to_factory
();
}
/**
\class Factory
\brief Représente une fabrique fabriquant des objets de classe mère Base
...
...
@@ -27,7 +33,7 @@ template <typename Base>
class
Factory
{
template
<
typename
_Base
,
typename
Child
>
friend
bool
register_to_factory
();
friend
bool
detail
::
register_to_factory
();
public:
//! \brief Retourne un objet créé à partir de choice
...
...
tests/factory_tests.cpp
View file @
f60086b4
...
...
@@ -33,9 +33,10 @@ REGISTER_FACTORY_ENTRY(Transition, GenerationsTransition);
void
CellulutTests
::
test_factory
()
{
QCOMPARE
(
Factory
<
Transition
>::
list_choices
().
size
(),
2
);
QCOMPARE
(
Factory
<
Transition
>::
list_choices
()[
0
],
"life-like"
);
QCOMPARE
(
Factory
<
Transition
>::
list_choices
()[
1
],
"generations"
);
QCOMPARE
(
Factory
<
Transition
>::
list_choices
().
size
(),
2ull
);
const
auto
choices
=
Factory
<
Transition
>::
list_choices
();
QCOMPARE
(
std
::
count
(
choices
.
begin
(),
choices
.
end
(),
"life-like"
),
1
);
QCOMPARE
(
std
::
count
(
choices
.
begin
(),
choices
.
end
(),
"generations"
),
1
);
std
::
unique_ptr
<
Transition
>
life_trans
=
Factory
<
Transition
>::
make
(
"life-like"
);
...
...
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