Commit f60086b4 authored by Yann Boucher's avatar Yann Boucher
Browse files

Fixed issues in the Factory code and tests

parent 4c465de5
Pipeline #76823 passed with stages
in 16 seconds
......@@ -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
......
......@@ -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");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment