fix inconsistency in conception of HierarchyOrientationIndicator
while it's still not really clear how we'll use this helper and if we need it at all -- some weeks ago I changed its semantics to be strictly based on the delta to a reference level. Now this means, we could go below level zero, but this doesn't make any sense in the context of navigating a tree. Actually, our test case triggered this situation, which caused the reference level to wrap around, since it is stored in an unsigned variable. Thus I'll add a precondition to keep the level positive, and I'll change the test to comply.
This commit is contained in:
parent
a07eb58cef
commit
6b32d1f37d
2 changed files with 12 additions and 19 deletions
|
|
@ -85,6 +85,8 @@ namespace lib {
|
|||
OrientationIndicator&
|
||||
markRefLevel ()
|
||||
{
|
||||
REQUIRE (0 < ptrdiff_t(refLevel_) + offset_);
|
||||
|
||||
markRefLevel (refLevel_ + offset_);
|
||||
ENSURE (offset_ == 0);
|
||||
return *this;
|
||||
|
|
|
|||
|
|
@ -372,17 +372,17 @@ namespace test {
|
|||
OrientationIndicator orient;
|
||||
|
||||
CHECK (0 == orient);
|
||||
++orient;
|
||||
CHECK (+1 == orient);
|
||||
----orient;
|
||||
CHECK (-1 == orient);
|
||||
++++orient;
|
||||
CHECK (+2 == orient);
|
||||
orient.markRefLevel();
|
||||
CHECK ( 0 == orient);
|
||||
--orient;
|
||||
CHECK (-1 == orient);
|
||||
|
||||
orient.markRefLevel (2);
|
||||
orient.markRefLevel (4);
|
||||
CHECK (-3 == orient);
|
||||
|
||||
orient.markRefLevel (2);
|
||||
orient.markRefLevel (4);
|
||||
CHECK (-3 == orient);
|
||||
|
||||
orient -= orient;
|
||||
|
|
@ -390,25 +390,16 @@ namespace test {
|
|||
|
||||
++orient;
|
||||
CHECK (+1 == orient);
|
||||
orient.markRefLevel();
|
||||
|
||||
orient.markRefLevel (4);
|
||||
orient.markRefLevel (5);
|
||||
CHECK (-2 == orient);
|
||||
|
||||
orient.markRefLevel (2);
|
||||
CHECK (+1 == orient);
|
||||
orient.resetToRef();
|
||||
++orient;
|
||||
orient.markRefLevel(); // now at level == 3
|
||||
CHECK ( 0 == orient);
|
||||
orient.resetToRef(); // now at level == 4
|
||||
orient.markRefLevel (7);
|
||||
CHECK (-3 == orient);
|
||||
|
||||
orient += 200;
|
||||
orient -= 190;
|
||||
CHECK (+7 == orient);
|
||||
|
||||
OrientationIndicator o2(orient);
|
||||
o2.markRefLevel(12);
|
||||
o2.markRefLevel(16);
|
||||
CHECK (-2 == o2);
|
||||
CHECK (+7 == orient);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue