50 using LERR_(INVALID_SCOPE);
51 using LERR_(NOT_IN_SESSION);
52 using LERR_(EMPTY_SCOPE_PATH);
76 CHECK (startPlacement.isValid());
78 checkInvalidScopeDetection();
79 ScopePath testPath = buildPath (startPlacement);
80 checkRelations (testPath,startPlacement);
81 invalidPath (testPath,startPlacement);
83 check_Identity_and_Copy (startPlacement);
86 clear (testPath, index);
91 buildPath (
PMO& startPla)
93 Scope startScope (startPla);
99 CHECK (path.contains (startScope));
100 CHECK ( path.getLeaf() == path2.getLeaf());
101 CHECK (path2.getLeaf() == path3.getLeaf());
108 checkInvalidScopeDetection()
115 CHECK (!scopeOfEvil.
isValid());
121 CHECK (!theInvalidToken.
isValid());
122 CHECK (theInvalidToken.
empty());
130 Scope refScope(refPlacement);
144 CHECK (path1.contains (refPlacement));
146 Scope refScope (refPlacement);
147 CHECK (path1.contains (refScope));
148 CHECK (path1.
endsAt (refScope));
151 CHECK (path2.contains (refScope));
152 CHECK (path2.endsAt (refScope));
154 CHECK (path1 == path2);
155 CHECK (!isSameObject (path1,path2));
157 Scope parent = path2.moveUp();
158 CHECK (path2.endsAt (parent));
159 CHECK (path1.
endsAt (refScope));
161 CHECK (path1 != path2);
162 CHECK (path2 != path1);
163 CHECK (path1.contains (path2));
164 CHECK (!disjoint(path1,path2));
165 CHECK (path2 == commonPrefix(path1,path2));
166 CHECK (path2 == commonPrefix(path2,path1));
167 CHECK (path1 != commonPrefix(path1,path2));
168 CHECK (path1 != commonPrefix(path2,path1));
178 CHECK (!refPath.
empty());
180 CHECK (1 == refPath.length());
183 CHECK (!defaultPath);
184 CHECK (refPath == defaultPath);
197 CHECK (isnil (invalidP));
201 CHECK (refPath.contains (refPlacement));
202 CHECK (!invalidP.contains (refPlacement));
204 Scope refScope (refPlacement);
205 CHECK (!invalidP.contains (refScope));
208 CHECK (refPath.contains (invalidP));
209 CHECK (!invalidP.contains (refPath));
210 CHECK (invalidP == commonPrefix(refPath,invalidP));
211 CHECK (invalidP == commonPrefix(invalidP,refPath));
214 Scope root = refPath.goRoot();
215 CHECK (1 == refPath.length());
217 Scope const& nil = refPath.moveUp();
218 CHECK (refPath.
empty());
219 CHECK (!nil.isValid());
220 CHECK (refPath == invalidP);
221 CHECK (invalidP.contains (nil));
222 CHECK (invalidP.contains (refPath));
223 CHECK (!invalidP.contains (refScope));
225 VERIFY_ERROR (EMPTY_SCOPE_PATH, refPath.navigate(root) );
232 check_Identity_and_Copy (
PMO& refPlacement)
234 Scope startScope (refPlacement);
239 CHECK (path1.contains (startScope));
240 CHECK (path2.contains (startScope));
241 CHECK (path3.contains (startScope));
243 CHECK (path1 == path2);
244 CHECK (path2 == path3);
245 CHECK (path1 == path3);
246 CHECK (!isSameObject (path1,path2));
247 CHECK (!isSameObject (path2,path3));
248 CHECK (!isSameObject (path1,path3));
250 Scope parent = path3.moveUp();
251 CHECK (parent == path2.getLeaf().
getParent());
253 CHECK (path1 == path2);
254 CHECK (path2 != path3);
255 CHECK (path1 != path3);
258 CHECK (path1 != path2);
259 CHECK (path2 == path3);
260 CHECK (path1 != path3);
263 CHECK (path1 != path2);
264 CHECK (path2 != path3);
265 CHECK (path1 != path3);
275 Scope startScope (refPlacement);
280 CHECK (!isSameObject (path1,path2));
281 CHECK (0 == path1.ref_count());
282 CHECK (0 == path2.ref_count());
285 CHECK (0 == path1.ref_count());
286 CHECK (0 < path2.ref_count());
289 CHECK (0 == path3.ref_count());
294 CHECK (path1 != path3);
297 CHECK (path1 == path3);
299 intrusive_ptr_release (&path2);
300 CHECK (0 == path1.ref_count());
301 CHECK (0 == path2.ref_count());
318 #define __SHOWPATH(N) cout << "Step("<<N<<"): "<< path << endl; 321 CHECK (path == refPath);
323 Scope leaf = path.getLeaf();
324 Scope parent = path.moveUp(); __SHOWPATH(2)
325 CHECK (path != refPath);
326 CHECK (refPath.contains (path));
327 CHECK (refPath.
endsAt (leaf));
328 CHECK (path.
endsAt (parent));
330 CHECK (parent == path.getLeaf());
332 Scope root = path.goRoot(); __SHOWPATH(3)
333 CHECK (path != refPath);
334 CHECK (path.
endsAt (root));
335 CHECK (refPath.contains (path));
336 CHECK (!path.
endsAt (parent));
337 CHECK (!path.
endsAt (leaf));
339 path.navigate (parent); __SHOWPATH(4)
340 CHECK (path.
endsAt (parent));
341 CHECK (!path.
endsAt (root));
342 CHECK (!path.
endsAt (leaf));
345 PMO& parentRefPoint = parent.getTop();
348 index->insert (newNode, parentRefPoint));
349 path.navigate (newLocation); __SHOWPATH(5)
350 Scope sibling = path.getLeaf();
351 CHECK (sibling == newLocation);
353 CHECK (path.
endsAt (sibling));
354 CHECK (path.contains (parent));
355 CHECK (path.contains (root));
356 CHECK (!refPath.contains (path));
357 CHECK (!path.contains (refPath));
358 CHECK (!disjoint (path,refPath));
359 CHECK (!disjoint (refPath,path));
361 ScopePath prefix = commonPrefix (path,refPath);
362 CHECK (prefix == commonPrefix (refPath,path));
363 CHECK (prefix.
endsAt (parent));
364 CHECK (!prefix.contains (leaf));
365 CHECK (!prefix.contains (sibling));
366 path.navigate (prefix.getLeaf()); __SHOWPATH(6)
367 CHECK (path == prefix);
370 ScopePath beforeInvalidNavigation = path;
372 VERIFY_ERROR (INVALID_SCOPE, path.navigate (unrelatedScope) );
373 CHECK (path == beforeInvalidNavigation);
378 retrieve_firstTestSubMO21()));
379 path.navigate (separatePlacement);
381 CHECK (disjoint (path,refPath));
382 CHECK (path.contains(separatePlacement));
383 Scope other = path.getLeaf();
384 CHECK (isSameObject (other.getTop(), separatePlacement));
385 ScopePath rootPrefix = commonPrefix (path,refPath);
386 CHECK (rootPrefix.
endsAt (root));
395 PMO& rootNode = index->getRoot();
396 CHECK (path.getLeaf() != rootNode);
400 CHECK (!isnil (path));
401 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.
Simple 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, bypassing any custom comparison operators.