Implementation of List Diff detection finished. Unit Test PASS

This commit is contained in:
Fischlurch 2015-01-04 15:13:16 +01:00
parent a12a739f05
commit 55b2c79aad
3 changed files with 20 additions and 8 deletions

View file

@ -74,7 +74,15 @@ namespace diff{
using std::swap;
/**
* Detect and describe changes in a monitored data sequence.
* The DiffDetector takes snapshot(s) of the observed data,
* to find all differences between the last snapshot and the
* current state. Whenever such a "List Diff" is pulled, a new
* baseline snapshot is taken automatically. The description of
* all changes can be retrieved from the returned diff iterator,
* as a sequence of \link ListDiffLanguage diff verbs\endlink
*/
template<class SEQ>
class DiffDetector
: boost::noncopyable
@ -103,13 +111,18 @@ namespace diff{
/** does the current state of the underlying sequence differ
* from the state embodied into the last reference snapshot taken?
* from the state embodied into the last reference snapshot taken?
* @remarks will possibly evaluate and iterate the whole sequence
*/
bool
isChanged() const
{
UNIMPLEMENTED("change detection");
auto snapshot = refIdx_.begin();
for (auto const& elm : currentData_)
if (snapshot != refIdx_.end() && elm != *snapshot++)
return true;
return false;
}
@ -190,7 +203,7 @@ namespace diff{
friend void
iterNext (DiffFrame & frame)
{
frame.establishNextState();
frame.currentStep_ = frame.establishNextState();
}
private:

View file

@ -73,7 +73,6 @@ namespace test{
, skip(a5)
, ins(b4)
});
}
}//(End)Test fixture

View file

@ -57,7 +57,7 @@ namespace test{
DiffStep_CTOR(pick);
DiffStep_CTOR(find);
DiffStep_CTOR(skip);
}//(End)Test fixture
@ -95,7 +95,7 @@ namespace test{
auto changes = detector.pullUpdate();
CHECK (!isnil (changes));
CHECK (!detector.isChanged());
CHECK (!detector.isChanged()); // pullUpdate() also took a new snapshot
DiffSeq generatedDiff;
append_all (changes, generatedDiff);
@ -108,8 +108,8 @@ namespace test{
, ins(b2)
, ins(b3)
, pick(a4)
, skip(a5)
, ins(b4)
, skip(a5)
}));
}
};