2014-12-01 02:50:46 +01:00
|
|
|
|
/*
|
|
|
|
|
|
DiffListApplication(Test) - demonstrate linearised representation of list diffs
|
|
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2014, Hermann Vosseler <Ichthyostega@web.de>
|
2014-12-01 02:50:46 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** is free software; you can redistribute it and/or modify it
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
|
|
Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
|
option) any later version. See the file COPYING for further details.
|
2014-12-01 02:50:46 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2014-12-01 02:50:46 +01:00
|
|
|
|
|
2017-02-22 01:54:20 +01:00
|
|
|
|
/** @file diff-list-application-test.cpp
|
2017-02-22 03:17:18 +01:00
|
|
|
|
** unit test \ref DiffListApplication_test
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2014-12-01 02:50:46 +01:00
|
|
|
|
|
|
|
|
|
|
#include "lib/test/run.hpp"
|
2014-12-15 03:21:19 +01:00
|
|
|
|
#include "lib/diff/list-diff-application.hpp"
|
2014-12-10 04:33:53 +01:00
|
|
|
|
#include "lib/iter-adapter-stl.hpp"
|
2014-12-15 03:21:19 +01:00
|
|
|
|
#include "lib/util.hpp"
|
2014-12-01 02:50:46 +01:00
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
2014-12-15 03:21:19 +01:00
|
|
|
|
using lib::iter_stl::snapshot;
|
2014-12-01 02:50:46 +01:00
|
|
|
|
using util::isnil;
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace lib {
|
2014-12-15 03:21:19 +01:00
|
|
|
|
namespace diff{
|
2014-12-01 02:50:46 +01:00
|
|
|
|
namespace test{
|
2014-12-11 04:46:47 +01:00
|
|
|
|
|
2014-12-14 03:47:23 +01:00
|
|
|
|
namespace {//Test fixture....
|
2014-12-01 02:50:46 +01:00
|
|
|
|
|
2014-12-04 04:41:07 +01:00
|
|
|
|
using DataSeq = vector<string>;
|
2014-12-01 02:50:46 +01:00
|
|
|
|
|
|
|
|
|
|
#define TOK(id) id(STRINGIFY(id))
|
|
|
|
|
|
|
|
|
|
|
|
string TOK(a1), TOK(a2), TOK(a3), TOK(a4), TOK(a5);
|
|
|
|
|
|
string TOK(b1), TOK(b2), TOK(b3), TOK(b4);
|
2014-12-10 04:33:53 +01:00
|
|
|
|
|
2014-12-14 03:47:23 +01:00
|
|
|
|
using Interpreter = ListDiffInterpreter<string>;
|
|
|
|
|
|
using DiffStep = ListDiffLanguage<string>::DiffStep;
|
|
|
|
|
|
using DiffSeq = iter_stl::IterSnapshot<DiffStep>;
|
|
|
|
|
|
|
|
|
|
|
|
DiffStep_CTOR(ins);
|
|
|
|
|
|
DiffStep_CTOR(del);
|
|
|
|
|
|
DiffStep_CTOR(pick);
|
2015-01-02 13:18:25 +01:00
|
|
|
|
DiffStep_CTOR(find);
|
|
|
|
|
|
DiffStep_CTOR(skip);
|
2014-12-14 03:47:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline DiffSeq
|
|
|
|
|
|
generateTestDiff()
|
|
|
|
|
|
{
|
|
|
|
|
|
return snapshot({del(a1)
|
|
|
|
|
|
, del(a2)
|
|
|
|
|
|
, ins(b1)
|
|
|
|
|
|
, pick(a3)
|
2015-01-02 13:18:25 +01:00
|
|
|
|
, find(a5)
|
2014-12-14 03:47:23 +01:00
|
|
|
|
, ins(b2)
|
|
|
|
|
|
, ins(b3)
|
|
|
|
|
|
, pick(a4)
|
2015-01-02 13:18:25 +01:00
|
|
|
|
, skip(a5)
|
2014-12-14 03:47:23 +01:00
|
|
|
|
, ins(b4)
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}//(End)Test fixture
|
2014-12-01 02:50:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
|
* @test Demonstration/Concept: a description language for list differences.
|
|
|
|
|
|
* The representation is given as a linearised sequence of verb tokens.
|
|
|
|
|
|
* This test demonstrates the application of such a diff representation
|
|
|
|
|
|
* to a given source list, transforming this list to hold the intended
|
|
|
|
|
|
* target list contents.
|
|
|
|
|
|
*
|
2015-10-02 18:47:44 +02:00
|
|
|
|
* @see DiffListGeneration_test
|
|
|
|
|
|
* @see DiffTreeApplication_test
|
|
|
|
|
|
* @see VerbFunctionDispatch_test
|
2014-12-01 02:50:46 +01:00
|
|
|
|
*/
|
|
|
|
|
|
class DiffListApplication_test : public Test
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
|
|
run (Arg)
|
|
|
|
|
|
{
|
2014-12-04 04:41:07 +01:00
|
|
|
|
DataSeq src({a1,a2,a3,a4,a5});
|
2015-04-03 20:10:22 +02:00
|
|
|
|
DiffSeq diff = generateTestDiff();
|
2014-12-01 02:50:46 +01:00
|
|
|
|
CHECK (!isnil (diff));
|
|
|
|
|
|
|
|
|
|
|
|
DataSeq target = src;
|
|
|
|
|
|
DiffApplicator<DataSeq> application(target);
|
|
|
|
|
|
application.consume(diff);
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (isnil (diff));
|
|
|
|
|
|
CHECK (!isnil (target));
|
|
|
|
|
|
CHECK (src != target);
|
|
|
|
|
|
CHECK (target == DataSeq({b1,a3,a5,b2,b3,a4,b4}));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
|
LAUNCHER (DiffListApplication_test, "unit common");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-15 03:21:19 +01:00
|
|
|
|
}}} // namespace lib::diff::test
|