Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
diff-list-application-test.cpp
Go to the documentation of this file.
1/*
2 DiffListApplication(Test) - demonstrate linearised representation of list diffs
3
4 Copyright (C)
5 2014, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
19#include "lib/test/run.hpp"
22#include "lib/util.hpp"
23
24#include <string>
25#include <vector>
26
28using util::isnil;
29using std::string;
30using std::vector;
31
32
33namespace lib {
34namespace diff{
35namespace test{
36
37 namespace {//Test fixture....
38
39 using DataSeq = vector<string>;
40
41 #define TOK(id) id(STRINGIFY(id))
42
43 string TOK(a1), TOK(a2), TOK(a3), TOK(a4), TOK(a5);
44 string TOK(b1), TOK(b2), TOK(b3), TOK(b4);
45
49
55
56
57 inline DiffSeq
59 {
60 return snapshot({del(a1)
61 , del(a2)
62 , ins(b1)
63 , pick(a3)
64 , find(a5)
65 , ins(b2)
66 , ins(b3)
67 , pick(a4)
68 , skip(a5)
69 , ins(b4)
70 });
71 }
72 }//(End)Test fixture
73
74
75
76
77
78
79
80
81
82 /***********************************************************************/
93 class DiffListApplication_test : public Test
94 {
95
96 virtual void
97 run (Arg)
98 {
99 DataSeq src({a1,a2,a3,a4,a5});
100 DiffSeq diff = generateTestDiff();
101 CHECK (!isnil (diff));
102
103 DataSeq target = src;
104 DiffApplicator<DataSeq> application(target);
105 application.consume(diff);
106
107 CHECK (isnil (diff));
108 CHECK (!isnil (target));
109 CHECK (src != target);
110 CHECK (target == DataSeq({b1,a3,a5,b2,b3,a4,b4}));
111 }
112 };
113
114
117
118
119
120}}} // namespace lib::diff::test
generic builder to apply a diff description to a given target data structure.
Interpreter interface to define the operations ("verbs"), which describe differences or changes in a ...
Definition list-diff.hpp:64
materialised iterator contents.
#define TOK(id)
#define DiffStep_CTOR(_ID_)
shortcut to define tokens of the diff language.
Preconfigured adapters for some STL container standard usage situations.
Apply a "list diff" to a concrete sequence of elements in a container.
ContentSnapshot< CON > snapshot(CON const &con)
Take a snapshot of the given STL compliant container.
Implementation namespace for support and library code.
Test runner and basic definitions for tests.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...