41 const uint MAX_ID = 1000;
51 ,instanceID_(
rani(MAX_ID))
54 virtual operator string()
const 56 return util::typeStr(
this)
57 + TestTargetObj::operator string();
60 uint Sub::created = 0;
99 verify_defaultSingletonCreation();
100 verify_SubclassCreation();
101 verify_FactoryDefinition_is_sticky();
102 verify_customFactory();
103 verify_automaticReplacement();
108 verify_defaultSingletonCreation()
113 Sub & o1 = accessor1();
114 Sub & o2 = accessor2();
115 CHECK (isSameObject (o1, o2));
120 verify_SubclassCreation()
128 SubSub& oSub = specialAccessor();
129 Sub& o = genericAccessor();
131 CHECK (!isSameObject (oSub, o));
138 verify_FactoryDefinition_is_sticky()
142 SubSub& oSub = otherSpecialAccessor();
147 SubSub& yetAnotherInstance = yetAnotherSpecialAccessor();
148 CHECK (
INSTANCEOF (SubSubSub, &yetAnotherInstance));
151 CHECK (isSameObject (oSub, yetAnotherInstance));
156 verify_customFactory()
162 CHECK (
INSTANCEOF (SubSubDub, &customised()));
163 CHECK (MAX_ID + 10 == customised().instanceID_);
167 customFactoryFunction (
void)
169 SubSubDub* specialInstance =
new SubSubDub;
170 specialInstance->instanceID_ = MAX_ID + 10;
171 return specialInstance;
177 verify_automaticReplacement()
180 Sub& original = genericAccessor();
181 uint oID = original.instanceID_;
186 Sub& replacement = genericAccessor();
187 CHECK ( isSameObject (replacement, *mockObject));
188 CHECK (!isSameObject (original, replacement));
193 CHECK(!isSameObject (replacement, special() ));
194 CHECK(!isSameObject (replacement, custom() ));
197 Sub& nextFetch = genericAccessor();
198 CHECK (isSameObject (original, nextFetch));
199 CHECK (oID == nextFetch.instanceID_);
204 Sub& replacement = genericAccessor();
205 uint repID = replacement.instanceID_;
209 CHECK (!
INSTANCEOF (SubSubSub, &replacement));
210 CHECK (!isSameObject (original, replacement));
213 Sub& otherAccess = anotherAccessor();
214 CHECK (isSameObject (replacement, otherAccess));
215 CHECK (repID == otherAccess.instanceID_);
216 CHECK (repID == replacement.instanceID_);
217 CHECK ( oID == original.instanceID_);
222 SubSub& subTypeAccess = genericSubTypeAccessor();
224 CHECK (!isSameObject (replacement, subTypeAccess));
225 CHECK (!isSameObject (original, subTypeAccess));
226 CHECK (repID != subTypeAccess.instanceID_);
227 CHECK ( oID != subTypeAccess.instanceID_);
230 CHECK (isSameObject (original, genericAccessor()));
231 CHECK (oID == genericAccessor().instanceID_);
Dummy target object to be created by factory for unit tests Used to verify sane memory management and...
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
Per type specific configuration of instances created as service dependencies.
int rani(uint bound=_iBOUND())
static void useSingleton()
configure dependency-injection for type SRV to build a subclass singleton.
Access point to singletons and other kinds of dependencies designated by type.
Implementation namespace for support and library code.
Target object to be created by Test-Factories or as Singleton.
This framework allows to (re)configure the lib::Depend front-end for dependency-injection.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Singleton services and Dependency Injection.
Configuration handle for temporarily shadowing a dependency by a test mock instance.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities. ...