41 using LERR_(INVALID_SCOPE);
42 using LERR_(NOT_IN_SESSION);
43 using LERR_(EMPTY_SCOPE_PATH);
67 CHECK (startPlacement.isValid());
69 checkInvalidScopeDetection();
70 ScopePath testPath = buildPath (startPlacement);
71 checkRelations (testPath,startPlacement);
72 invalidPath (testPath,startPlacement);
74 check_Identity_and_Copy (startPlacement);
77 clear (testPath, index);
82 buildPath (
PMO& startPla)
84 Scope startScope (startPla);
90 CHECK (path.contains (startScope));
91 CHECK ( path.getLeaf() == path2.getLeaf());
92 CHECK (path2.getLeaf() == path3.getLeaf());
99 checkInvalidScopeDetection()
106 CHECK (!scopeOfEvil.
isValid());
112 CHECK (!theInvalidToken.
isValid());
113 CHECK (theInvalidToken.
empty());
121 Scope refScope(refPlacement);
135 CHECK (path1.contains (refPlacement));
137 Scope refScope (refPlacement);
138 CHECK (path1.contains (refScope));
139 CHECK (path1.
endsAt (refScope));
142 CHECK (path2.contains (refScope));
143 CHECK (path2.endsAt (refScope));
145 CHECK (path1 == path2);
146 CHECK (!isSameObject (path1,path2));
148 Scope parent = path2.moveUp();
149 CHECK (path2.endsAt (parent));
150 CHECK (path1.
endsAt (refScope));
152 CHECK (path1 != path2);
153 CHECK (path2 != path1);
154 CHECK (path1.contains (path2));
155 CHECK (!disjoint(path1,path2));
156 CHECK (path2 == commonPrefix(path1,path2));
157 CHECK (path2 == commonPrefix(path2,path1));
158 CHECK (path1 != commonPrefix(path1,path2));
159 CHECK (path1 != commonPrefix(path2,path1));
169 CHECK (!refPath.
empty());
171 CHECK (1 == refPath.length());
174 CHECK (!defaultPath);
175 CHECK (refPath == defaultPath);
188 CHECK (isnil (invalidP));
192 CHECK (refPath.contains (refPlacement));
193 CHECK (!invalidP.contains (refPlacement));
195 Scope refScope (refPlacement);
196 CHECK (!invalidP.contains (refScope));
199 CHECK (refPath.contains (invalidP));
200 CHECK (!invalidP.contains (refPath));
201 CHECK (invalidP == commonPrefix(refPath,invalidP));
202 CHECK (invalidP == commonPrefix(invalidP,refPath));
205 Scope root = refPath.goRoot();
206 CHECK (1 == refPath.length());
208 Scope const& nil = refPath.moveUp();
209 CHECK (refPath.
empty());
210 CHECK (!nil.isValid());
211 CHECK (refPath == invalidP);
212 CHECK (invalidP.contains (nil));
213 CHECK (invalidP.contains (refPath));
214 CHECK (!invalidP.contains (refScope));
216 VERIFY_ERROR (EMPTY_SCOPE_PATH, refPath.navigate(root) );
223 check_Identity_and_Copy (
PMO& refPlacement)
225 Scope startScope (refPlacement);
230 CHECK (path1.contains (startScope));
231 CHECK (path2.contains (startScope));
232 CHECK (path3.contains (startScope));
234 CHECK (path1 == path2);
235 CHECK (path2 == path3);
236 CHECK (path1 == path3);
237 CHECK (!isSameObject (path1,path2));
238 CHECK (!isSameObject (path2,path3));
239 CHECK (!isSameObject (path1,path3));
241 Scope parent = path3.moveUp();
242 CHECK (parent == path2.getLeaf().
getParent());
244 CHECK (path1 == path2);
245 CHECK (path2 != path3);
246 CHECK (path1 != path3);
249 CHECK (path1 != path2);
250 CHECK (path2 == path3);
251 CHECK (path1 != path3);
254 CHECK (path1 != path2);
255 CHECK (path2 != path3);
256 CHECK (path1 != path3);
266 Scope startScope (refPlacement);
271 CHECK (!isSameObject (path1,path2));
272 CHECK (0 == path1.ref_count());
273 CHECK (0 == path2.ref_count());
276 CHECK (0 == path1.ref_count());
277 CHECK (0 < path2.ref_count());
280 CHECK (0 == path3.ref_count());
285 CHECK (path1 != path3);
288 CHECK (path1 == path3);
290 intrusive_ptr_release (&path2);
291 CHECK (0 == path1.ref_count());
292 CHECK (0 == path2.ref_count());
309 #define __SHOWPATH(N) cout << "Step("<<N<<"): "<< path << endl; 312 CHECK (path == refPath);
314 Scope leaf = path.getLeaf();
315 Scope parent = path.moveUp(); __SHOWPATH(2)
316 CHECK (path != refPath);
317 CHECK (refPath.contains (path));
318 CHECK (refPath.
endsAt (leaf));
319 CHECK (path.
endsAt (parent));
321 CHECK (parent == path.getLeaf());
323 Scope root = path.goRoot(); __SHOWPATH(3)
324 CHECK (path != refPath);
325 CHECK (path.
endsAt (root));
326 CHECK (refPath.contains (path));
327 CHECK (!path.
endsAt (parent));
328 CHECK (!path.
endsAt (leaf));
330 path.navigate (parent); __SHOWPATH(4)
331 CHECK (path.
endsAt (parent));
332 CHECK (!path.
endsAt (root));
333 CHECK (!path.
endsAt (leaf));
336 PMO& parentRefPoint = parent.getTop();
339 index->insert (newNode, parentRefPoint));
340 path.navigate (newLocation); __SHOWPATH(5)
341 Scope sibling = path.getLeaf();
342 CHECK (sibling == newLocation);
344 CHECK (path.
endsAt (sibling));
345 CHECK (path.contains (parent));
346 CHECK (path.contains (root));
347 CHECK (!refPath.contains (path));
348 CHECK (!path.contains (refPath));
349 CHECK (!disjoint (path,refPath));
350 CHECK (!disjoint (refPath,path));
352 ScopePath prefix = commonPrefix (path,refPath);
353 CHECK (prefix == commonPrefix (refPath,path));
354 CHECK (prefix.
endsAt (parent));
355 CHECK (!prefix.contains (leaf));
356 CHECK (!prefix.contains (sibling));
357 path.navigate (prefix.getLeaf()); __SHOWPATH(6)
358 CHECK (path == prefix);
361 ScopePath beforeInvalidNavigation = path;
363 VERIFY_ERROR (INVALID_SCOPE, path.navigate (unrelatedScope) );
364 CHECK (path == beforeInvalidNavigation);
369 retrieve_firstTestSubMO21()));
370 path.navigate (separatePlacement);
372 CHECK (disjoint (path,refPath));
373 CHECK (path.contains(separatePlacement));
374 Scope other = path.getLeaf();
375 CHECK (isSameObject (other.getTop(), separatePlacement));
376 ScopePath rootPrefix = commonPrefix (path,refPath);
377 CHECK (rootPrefix.
endsAt (root));
386 PMO& rootNode = index->getRoot();
387 CHECK (path.getLeaf() != rootNode);
391 CHECK (!isnil (path));
392 CHECK (path.getLeaf() == rootNode);
void check_RefcountProtection(PMO &refPlacement)
Unit test helper to generate deliberately wrong placement scopes.
Test MObject subclass, which, contrary to any real MObject, can be created directly without involving...
Scope getParent() const
retrieve the parent scope which encloses this scope.
bool endsAt(Scope const &) const
verify the scope in question is equivalent to our leaf scope.
bool empty() const
an empty path doesn't even contain a root element.
static const ScopePath INVALID
constant invalid path token.
PPIdx build_testScopes()
helper for tests: create a pseudo-session (actually just a PlacementIndex), which contains some neste...
Scope const & fabricate_invalidScope()
void intrusive_ptr_add_ref(ScopePath *pathFrame)
management function for boost::intrusive_ptr to be picked up by ADL
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Steam-Layer implementation namespace root.
Namespace of Session and user visible high-level objects.
Sequence of nested scopes within the high-level model.
A Placement scope within the high-level-model.
bool isValid() const
check if this scope can be located.
PlacementMO & retrieve_startElm()
complement to the helper: retrieve one of the dummy placements which is a Placement<> and way down in...
Unit test helper to generate a system of nested test scopes.
ScopeQuery< MObject >::iterator explore_testScope(PlacementMO const &scopeTop)
shortcut to explore the contents of a scope within the current index.
Core of the session implementation datastructure.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A collection of frequently used helper functions to support unit testing.
void navigate(const ScopePath refPath, PPIdx index)
bool isValid() const
a valid path consists of more than just the root element.
static const Scope INVALID
constant invalid scope token.
An Object representing a sequence of nested scopes within the Session.
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities. ...