8#include <gtest/gtest.h>
10#include "arcane/utils/internal/DependencyInjection.h"
11#include "arcane/utils/FatalErrorException.h"
13#include "arcane/utils/ITraceMng.h"
22using namespace Arcane::DependencyInjection;
27 virtual ~IA() =
default;
28 virtual int value()
const = 0;
34 virtual ~IB() =
default;
35 virtual int value()
const = 0;
41 virtual ~IA2() =
default;
42 virtual int value()
const = 0;
43 virtual IB* bValue()
const = 0;
49 virtual ~IB2() =
default;
50 virtual int value()
const = 0;
51 virtual String stringValue()
const = 0;
57 virtual ~IC() =
default;
58 virtual int value()
const = 0;
64 virtual ~ID() =
default;
70 virtual ~IE() =
default;
71 virtual int intValue()
const = 0;
72 virtual String stringValue()
const = 0;
79 virtual ~INone() =
default;
87 int value()
const override {
return 5; }
95 int value()
const override {
return 12; }
105 int value()
const override {
return 32; }
106 String stringValue()
const override {
return m_test; }
121 int intValue()
const override {
return m_int_value; }
122 String stringValue()
const override {
return m_string_value; }
134 CDImpl(
int a,
double b) : m_int_value(a+(
int)
b){}
135 CDImpl(
int a) : m_int_value(a){}
136 CDImpl() : m_int_value(2){}
137 int value()
const override {
return m_int_value; }
153 int value()
const override {
return m_a; }
154 IB* bValue()
const override {
return m_ib; }
161ARCANE_DI_REGISTER_PROVIDER(
AImpl,
163 ARCANE_DI_INTERFACES(
IA),
164 ARCANE_DI_EMPTY_CONSTRUCTOR());
166ARCANE_DI_REGISTER_PROVIDER(
BImpl,
168 ARCANE_DI_INTERFACES(
IB),
169 ARCANE_DI_EMPTY_CONSTRUCTOR());
171ARCANE_DI_REGISTER_PROVIDER(
B2Impl,
173 ARCANE_DI_INTERFACES(
IB2),
174 ARCANE_DI_CONSTRUCTOR(
String));
176ARCANE_DI_REGISTER_PROVIDER(
EImpl,
178 ARCANE_DI_INTERFACES(
IE),
181ARCANE_DI_REGISTER_PROVIDER(
A2Impl,
183 ARCANE_DI_INTERFACES(
IA2),
184 ARCANE_DI_CONSTRUCTOR(
int,
IB*));
186ARCANE_DI_REGISTER_PROVIDER(
CDImpl,
188 ARCANE_DI_INTERFACES(
IC,
ID),
189 ARCANE_DI_CONSTRUCTOR(
int));
191ARCANE_DI_REGISTER_PROVIDER(
CDImpl,
193 ARCANE_DI_INTERFACES(
IC),
194 ARCANE_DI_EMPTY_CONSTRUCTOR());
196ARCANE_DI_REGISTER_PROVIDER(
CDImpl,
198 ARCANE_DI_INTERFACES(
IC,
ID),
199 ARCANE_DI_CONSTRUCTOR(
int),
200 ARCANE_DI_CONSTRUCTOR(
int,
double),
201 ARCANE_DI_EMPTY_CONSTRUCTOR());
206 using namespace Arcane::DependencyInjection;
210 std::cout <<
"FACTORIES=" <<
injector.printFactories() <<
"\n";
215template <
typename T>
void
220 FAIL() <<
"Expected FatalErrorException";
223 std::cout <<
"EX=" <<
ex <<
"\n";
226 FAIL() <<
"Expected FatalErrorException";
233 using namespace Arcane::DependencyInjection;
234 using namespace DI_Test;
247 using namespace Arcane::DependencyInjection;
248 std::cout <<
"INJECTOR TEST\n";
250 ITraceMng*
tm = Arccore::arccoreCreateDefaultTraceMng();
254 std::cout <<
"TM=" <<
tm <<
"TM2=" <<
tm2.get() <<
"\n";
260 using namespace Arcane::DependencyInjection;
261 using namespace DI_Test;
281 using namespace Arcane::DependencyInjection;
282 using namespace DI_Test;
325 std::cerr <<
"ERROR=" <<
ex <<
"\n";
332 using namespace DI_Test;
333 namespace di = Arcane::DependencyInjection;
336 di::impl::ConcreteFactory<IA2, A2Impl, ConstructorType>
c2f;
351 std::cerr <<
"ERROR=" <<
ex <<
"\n";
356TEST(DependencyInjection,Impl2)
358 using namespace DI_Test;
359 namespace di = Arcane::DependencyInjection;
396 std::cerr <<
"ERROR=" <<
ex <<
"\n";
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Classe de base d'une exception.
Exception lorsqu'une erreur fatale est survenue.
Interface du gestionnaire de traces.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-