OTest2
A C++ testing framework
difflogblock.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Ondrej Starek
3  *
4  * This file is part of OTest2.
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OTest2__LIB_DIFFLOGBLOCK_H_
21 #define OTest2__LIB_DIFFLOGBLOCK_H_
22 
23 #include <vector>
24 
25 #include <otest2/hirschberg.h>
26 
27 namespace OTest2 {
28 
32 struct DiffBlock {
34  int left_end;
36  int right_end;
37 };
38 
42 typedef std::vector<DiffBlock> DiffLogBlocks;
43 
48  private:
49  DiffLogBlocks* blocks;
50  bool opened_block;
51  int curr_left;
52  int curr_right;
53 
54  void openBlock();
55 
56  public:
62  explicit DiffLogBuilderBlock(
63  DiffLogBlocks* blocks_);
64 
68  virtual ~DiffLogBuilderBlock();
69 
70  /* -- avoid copying */
72  const DiffLogBuilderBlock&) = delete;
74  const DiffLogBuilderBlock&) = delete;
75 
76  /* -- diff log builder interface */
77  virtual void addMatch(
78  int left_index_,
79  int right_index_);
80  virtual void addChange(
81  int left_index_,
82  int right_index_);
83  virtual void addDelete(
84  int right_index_);
85  virtual void addInsert(
86  int left_index_);
87 };
88 
89 } /* namespace OTest2 */
90 
91 #endif /* OTest2__LIB_DIFFLOGBLOCK_H_ */
OTest2::DiffLogBuilderBlock::~DiffLogBuilderBlock
virtual ~DiffLogBuilderBlock()
Dtor.
Definition: difflogblock.cpp:48
OTest2::DiffLogBuilderBlock::addMatch
virtual void addMatch(int left_index_, int right_index_)
Add match of characters in both sequences.
Definition: difflogblock.cpp:61
OTest2::DiffLogBlocks
std::vector< DiffBlock > DiffLogBlocks
Ordered (indexes into the sequences) list of diff changes.
Definition: difflogblock.h:42
OTest2::DiffBlock::right_end
int right_end
Definition: difflogblock.h:36
OTest2::DiffLogBuilderBlock::operator=
DiffLogBuilderBlock & operator=(const DiffLogBuilderBlock &)=delete
OTest2::DiffLogBuilder
Generic interface of the log builder.
Definition: difflogbuilder.h:30
hirschberg.h
OTest2::DiffBlock::left_begin
int left_begin
Definition: difflogblock.h:33
OTest2
Definition: assertbean.h:25
OTest2::DiffBlock::left_end
int left_end
Definition: difflogblock.h:34
OTest2::DiffLogBuilderBlock::DiffLogBuilderBlock
DiffLogBuilderBlock(DiffLogBlocks *blocks_)
Ctor.
Definition: difflogblock.cpp:38
OTest2::DiffBlock::right_begin
int right_begin
Definition: difflogblock.h:35
OTest2::DiffBlock
One block change.
Definition: difflogblock.h:32
OTest2::DiffLogBuilderBlock::addInsert
virtual void addInsert(int left_index_)
Add inserted item to the left sequence.
Definition: difflogblock.cpp:94
OTest2::DiffLogBuilderBlock::addDelete
virtual void addDelete(int right_index_)
Add deleted item from the right sequence.
Definition: difflogblock.cpp:84
OTest2::DiffLogBuilderBlock
Log builder making records of whole blocks of changes.
Definition: difflogblock.h:47
OTest2::DiffLogBuilderBlock::addChange
virtual void addChange(int left_index_, int right_index_)
Add change of both sequences.
Definition: difflogblock.cpp:70