formatting and fixes
This commit is contained in:
parent
0e4c24a23d
commit
94d86a1c9f
127
.clang-format
Normal file
127
.clang-format
Normal file
@ -0,0 +1,127 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Auto
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
...
|
||||
|
10
.clang-tidy
Normal file
10
.clang-tidy
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,bugprone-*,concurrency-*,cppcoreguidelines-*,modernize-*,readability-*,-readability-redundant-access-specifiers,-readability-function-cognitive-complexity'
|
||||
ExtraArgs: '-Wno-unknown-warning-option'
|
||||
FormatStyle: none
|
||||
HeaderFileExtensions: ['', 'h','hh','hpp','hxx']
|
||||
HeaderFilterRegex: ''
|
||||
ImplementationFileExtensions: ['c','cc','cpp','cxx']
|
||||
User: 'scott.e.graves@protonmail.com'
|
||||
WarningsAsErrors: ''
|
||||
...
|
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2024-06-03 Scott E. Graves
|
||||
|
||||
* bugfix: fixed compilation issues with GCC 14
|
||||
* https://github.com/cubicdaiya/dtl/pull/22
|
||||
* https://github.com/cubicdaiya/dtl/pull/18
|
||||
* initialize variables to prevent warnings
|
||||
* https://github.com/cubicdaiya/dtl/pull/16
|
||||
|
||||
* 1.21 released
|
||||
|
||||
2022-04-11 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||
|
||||
* bugfix: fixed invalid offset in unified format difference when difference is too large.
|
||||
|
216
dtl/Diff.hpp
216
dtl/Diff.hpp
@ -6,8 +6,8 @@
|
||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
@ -44,12 +44,11 @@ namespace dtl {
|
||||
* diff class template
|
||||
* sequence must support random_access_iterator.
|
||||
*/
|
||||
template <typename elem, typename sequence = vector< elem >, typename comparator = Compare< elem > >
|
||||
class Diff
|
||||
{
|
||||
template <typename elem, typename sequence = vector<elem>,
|
||||
typename comparator = Compare<elem>>
|
||||
class Diff {
|
||||
private:
|
||||
dtl_typedefs(elem, sequence)
|
||||
sequence A;
|
||||
dtl_typedefs(elem, sequence) sequence A;
|
||||
sequence B;
|
||||
size_t M;
|
||||
size_t N;
|
||||
@ -69,112 +68,71 @@ namespace dtl {
|
||||
comparator cmp;
|
||||
long long ox;
|
||||
long long oy;
|
||||
|
||||
public:
|
||||
Diff() {}
|
||||
|
||||
Diff (const sequence& a,
|
||||
const sequence& b) : A(a), B(b), ses(false) {
|
||||
Diff(const sequence &a, const sequence &b) : A(a), B(b), ses(false) {
|
||||
init();
|
||||
}
|
||||
|
||||
Diff (const sequence& a,
|
||||
const sequence& b,
|
||||
bool deletesFirst) : A(a), B(b), ses(deletesFirst) {
|
||||
Diff(const sequence &a, const sequence &b, bool deletesFirst)
|
||||
: A(a), B(b), ses(deletesFirst) {
|
||||
init();
|
||||
}
|
||||
|
||||
Diff (const sequence& a,
|
||||
const sequence& b,
|
||||
const comparator& comp) : A(a), B(b), ses(false), cmp(comp) {
|
||||
Diff(const sequence &a, const sequence &b, const comparator &comp)
|
||||
: A(a), B(b), ses(false), cmp(comp) {
|
||||
init();
|
||||
}
|
||||
|
||||
Diff (const sequence& a,
|
||||
const sequence& b,
|
||||
bool deleteFirst,
|
||||
const comparator& comp) : A(a), B(b), ses(deleteFirst), cmp(comp) {
|
||||
Diff(const sequence &a, const sequence &b, bool deleteFirst,
|
||||
const comparator &comp)
|
||||
: A(a), B(b), ses(deleteFirst), cmp(comp) {
|
||||
init();
|
||||
}
|
||||
|
||||
~Diff() {}
|
||||
|
||||
long long getEditDistance () const {
|
||||
return editDistance;
|
||||
}
|
||||
long long getEditDistance() const { return editDistance; }
|
||||
|
||||
Lcs< elem > getLcs () const {
|
||||
return lcs;
|
||||
}
|
||||
Lcs<elem> getLcs() const { return lcs; }
|
||||
|
||||
elemVec getLcsVec () const {
|
||||
return lcs.getSequence();
|
||||
}
|
||||
elemVec getLcsVec() const { return lcs.getSequence(); }
|
||||
|
||||
Ses< elem > getSes () const {
|
||||
return ses;
|
||||
}
|
||||
Ses<elem> getSes() const { return ses; }
|
||||
|
||||
uniHunkVec getUniHunks () const {
|
||||
return uniHunks;
|
||||
}
|
||||
uniHunkVec getUniHunks() const { return uniHunks; }
|
||||
|
||||
/* These should be deprecated */
|
||||
bool isHuge () const {
|
||||
return huge;
|
||||
}
|
||||
bool isHuge() const { return huge; }
|
||||
|
||||
void onHuge () {
|
||||
this->huge = true;
|
||||
}
|
||||
void onHuge() { this->huge = true; }
|
||||
|
||||
void offHuge () {
|
||||
this->huge = false;
|
||||
}
|
||||
void offHuge() { this->huge = false; }
|
||||
|
||||
bool isUnserious () const {
|
||||
return trivial;
|
||||
}
|
||||
bool isUnserious() const { return trivial; }
|
||||
|
||||
void onUnserious () {
|
||||
this->trivial = true;
|
||||
}
|
||||
void onUnserious() { this->trivial = true; }
|
||||
|
||||
void offUnserious () {
|
||||
this->trivial = false;
|
||||
}
|
||||
void offUnserious() { this->trivial = false; }
|
||||
|
||||
void onOnlyEditDistance () {
|
||||
this->editDistanceOnly = true;
|
||||
}
|
||||
void onOnlyEditDistance() { this->editDistanceOnly = true; }
|
||||
|
||||
/* These are the replacements for the above */
|
||||
bool hugeEnabled () const {
|
||||
return huge;
|
||||
}
|
||||
bool hugeEnabled() const { return huge; }
|
||||
|
||||
void enableHuge () {
|
||||
this->huge = true;
|
||||
}
|
||||
void enableHuge() { this->huge = true; }
|
||||
|
||||
void disableHuge () {
|
||||
this->huge = false;
|
||||
}
|
||||
void disableHuge() { this->huge = false; }
|
||||
|
||||
bool trivialEnabled () const {
|
||||
return trivial;
|
||||
}
|
||||
bool trivialEnabled() const { return trivial; }
|
||||
|
||||
void enableTrivial () {
|
||||
this->trivial = true;
|
||||
}
|
||||
void enableTrivial() { this->trivial = true; }
|
||||
|
||||
void disableTrivial () {
|
||||
this->trivial = false;
|
||||
}
|
||||
void disableTrivial() { this->trivial = false; }
|
||||
|
||||
void editDistanceOnlyEnabled () {
|
||||
this->editDistanceOnly = true;
|
||||
}
|
||||
void editDistanceOnlyEnabled() { this->editDistanceOnly = true; }
|
||||
|
||||
/**
|
||||
* patching with Unified Format Hunks
|
||||
@ -232,7 +190,8 @@ namespace dtl {
|
||||
sesElemVec sesSeq = ses.getSequence();
|
||||
elemList seqLst(seq.begin(), seq.end());
|
||||
elemList_iter lstIt = seqLst.begin();
|
||||
for (sesElemVec_iter sesIt=sesSeq.begin();sesIt!=sesSeq.end();++sesIt) {
|
||||
for (sesElemVec_iter sesIt = sesSeq.begin(); sesIt != sesSeq.end();
|
||||
++sesIt) {
|
||||
switch (sesIt->second.type) {
|
||||
case SES_ADD:
|
||||
seqLst.insert(lstIt, sesIt->first);
|
||||
@ -254,8 +213,8 @@ namespace dtl {
|
||||
|
||||
/**
|
||||
* compose Longest Common Subsequence and Shortest Edit Script.
|
||||
* The algorithm implemented here is based on "An O(NP) Sequence Comparison Algorithm"
|
||||
* described by Sun Wu, Udi Manber and Gene Myers
|
||||
* The algorithm implemented here is based on "An O(NP) Sequence Comparison
|
||||
* Algorithm" described by Sun Wu, Udi Manber and Gene Myers
|
||||
*/
|
||||
void compose() {
|
||||
|
||||
@ -275,11 +234,15 @@ namespace dtl {
|
||||
for (long long k = -p; k <= static_cast<long long>(delta) - 1; ++k) {
|
||||
fp[k + offset] = snake(k, fp[k - 1 + offset] + 1, fp[k + 1 + offset]);
|
||||
}
|
||||
for (long long k=static_cast<long long>(delta)+p;k>=static_cast<long long>(delta)+1;--k) {
|
||||
for (long long k = static_cast<long long>(delta) + p;
|
||||
k >= static_cast<long long>(delta) + 1; --k) {
|
||||
fp[k + offset] = snake(k, fp[k - 1 + offset] + 1, fp[k + 1 + offset]);
|
||||
}
|
||||
fp[delta+offset] = snake(static_cast<long long>(delta), fp[delta-1+offset]+1, fp[delta+1+offset]);
|
||||
} while (fp[delta+offset] != static_cast<long long>(N) && pathCordinates.size() < MAX_CORDINATES_SIZE);
|
||||
fp[delta + offset] =
|
||||
snake(static_cast<long long>(delta), fp[delta - 1 + offset] + 1,
|
||||
fp[delta + 1 + offset]);
|
||||
} while (fp[delta + offset] != static_cast<long long>(N) &&
|
||||
pathCordinates.size() < MAX_CORDINATES_SIZE);
|
||||
|
||||
editDistance += static_cast<long long>(delta) + 2 * p;
|
||||
long long r = path[delta + offset];
|
||||
@ -312,15 +275,12 @@ namespace dtl {
|
||||
/**
|
||||
* print difference between A and B as an SES
|
||||
*/
|
||||
template < typename stream >
|
||||
void printSES (stream& out) const {
|
||||
template <typename stream> void printSES(stream &out) const {
|
||||
sesElemVec ses_v = ses.getSequence();
|
||||
for_each(ses_v.begin(), ses_v.end(), ChangePrinter<sesElem, stream>(out));
|
||||
}
|
||||
|
||||
void printSES (ostream& out = cout) const {
|
||||
printSES< ostream >(out);
|
||||
}
|
||||
void printSES(ostream &out = cout) const { printSES<ostream>(out); }
|
||||
|
||||
/**
|
||||
* print differences given an SES
|
||||
@ -347,7 +307,8 @@ namespace dtl {
|
||||
/**
|
||||
* store difference between A and B as an SES with custom storage
|
||||
*/
|
||||
template < typename storedData, template < typename SEET, typename STRT > class ST >
|
||||
template <typename storedData,
|
||||
template <typename SEET, typename STRT> class ST>
|
||||
void storeSES(storedData &sd) const {
|
||||
sesElemVec ses_v = ses.getSequence();
|
||||
for_each(ses_v.begin(), ses_v.end(), ST<sesElem, storedData>(sd));
|
||||
@ -356,9 +317,9 @@ namespace dtl {
|
||||
/**
|
||||
* print difference between A and B in the Unified Format
|
||||
*/
|
||||
template < typename stream >
|
||||
void printUnifiedFormat (stream& out) const {
|
||||
for_each(uniHunks.begin(), uniHunks.end(), UniHunkPrinter< sesElem, stream >(out));
|
||||
template <typename stream> void printUnifiedFormat(stream &out) const {
|
||||
for_each(uniHunks.begin(), uniHunks.end(),
|
||||
UniHunkPrinter<sesElem, stream>(out));
|
||||
}
|
||||
|
||||
void printUnifiedFormat(ostream &out = cout) const {
|
||||
@ -405,8 +366,10 @@ namespace dtl {
|
||||
middle = 0;
|
||||
++inc_dec_count;
|
||||
adds.push_back(*it);
|
||||
if (!isMiddle) isMiddle = true;
|
||||
if (isMiddle) ++d;
|
||||
if (!isMiddle)
|
||||
isMiddle = true;
|
||||
if (isMiddle)
|
||||
++d;
|
||||
if (l_cnt >= length) {
|
||||
joinSesVec(change, deletes);
|
||||
joinSesVec(change, adds);
|
||||
@ -417,8 +380,10 @@ namespace dtl {
|
||||
middle = 0;
|
||||
--inc_dec_count;
|
||||
deletes.push_back(*it);
|
||||
if (!isMiddle) isMiddle = true;
|
||||
if (isMiddle) ++b;
|
||||
if (!isMiddle)
|
||||
isMiddle = true;
|
||||
if (isMiddle)
|
||||
++b;
|
||||
if (l_cnt >= length) {
|
||||
joinSesVec(change, deletes);
|
||||
joinSesVec(change, adds);
|
||||
@ -426,8 +391,10 @@ namespace dtl {
|
||||
}
|
||||
break;
|
||||
case SES_COMMON:
|
||||
++b;++d;
|
||||
if (common[1].empty() && adds.empty() && deletes.empty() && change.empty()) {
|
||||
++b;
|
||||
++d;
|
||||
if (common[1].empty() && adds.empty() && deletes.empty() &&
|
||||
change.empty()) {
|
||||
if (static_cast<long long>(common[0].size()) < DTL_CONTEXT_SIZE) {
|
||||
if (a == 0 && c == 0) {
|
||||
if (!wasSwapped()) {
|
||||
@ -443,8 +410,10 @@ namespace dtl {
|
||||
rotate(common[0].begin(), common[0].begin() + 1, common[0].end());
|
||||
common[0].pop_back();
|
||||
common[0].push_back(*it);
|
||||
++a;++c;
|
||||
--b;--d;
|
||||
++a;
|
||||
++c;
|
||||
--b;
|
||||
--d;
|
||||
}
|
||||
}
|
||||
if (isMiddle && !isAfter) {
|
||||
@ -467,7 +436,8 @@ namespace dtl {
|
||||
if (isAfter && !change.empty()) {
|
||||
sesElemVec_iter cit = it;
|
||||
long long cnt = 0;
|
||||
for (long long i=0;i<DTL_SEPARATE_SIZE && (cit != ses_v.end());++i, ++cit) {
|
||||
for (long long i = 0; i < DTL_SEPARATE_SIZE && (cit != ses_v.end());
|
||||
++i, ++cit) {
|
||||
if (cit->second.type == SES_COMMON) {
|
||||
++cnt;
|
||||
}
|
||||
@ -488,9 +458,12 @@ namespace dtl {
|
||||
a += c0size - DTL_SEPARATE_SIZE;
|
||||
c += c0size - DTL_SEPARATE_SIZE;
|
||||
}
|
||||
if (a == 0) ++a;
|
||||
if (c == 0) ++c;
|
||||
if (wasSwapped()) swap(a, c);
|
||||
if (a == 0)
|
||||
++a;
|
||||
if (c == 0)
|
||||
++c;
|
||||
if (wasSwapped())
|
||||
swap(a, c);
|
||||
hunk.a = a;
|
||||
hunk.b = b;
|
||||
hunk.c = c;
|
||||
@ -515,9 +488,7 @@ namespace dtl {
|
||||
/**
|
||||
* compose ses from stream
|
||||
*/
|
||||
template <typename stream>
|
||||
static Ses< elem > composeSesFromStream (stream& st)
|
||||
{
|
||||
template <typename stream> static Ses<elem> composeSesFromStream(stream &st) {
|
||||
elem line;
|
||||
Ses<elem> ret;
|
||||
long long x_idx, y_idx;
|
||||
@ -568,18 +539,25 @@ namespace dtl {
|
||||
/**
|
||||
* search shortest path and record the path
|
||||
*/
|
||||
long long snake(const long long& k, const long long& above, const long long& below) {
|
||||
long long r = above > below ? path[(size_t)k-1+offset] : path[(size_t)k+1+offset];
|
||||
long long snake(const long long &k, const long long &above,
|
||||
const long long &below) {
|
||||
long long r = above > below ? path[(size_t)k - 1 + offset]
|
||||
: path[(size_t)k + 1 + offset];
|
||||
long long y = max(above, below);
|
||||
long long x = y - k;
|
||||
while ((size_t)x < M && (size_t)y < N && (swapped ? cmp.impl(B[(size_t)y], A[(size_t)x]) : cmp.impl(A[(size_t)x], B[(size_t)y]))) {
|
||||
++x;++y;
|
||||
while ((size_t)x < M && (size_t)y < N &&
|
||||
(swapped ? cmp.impl(B[(size_t)y], A[(size_t)x])
|
||||
: cmp.impl(A[(size_t)x], B[(size_t)y]))) {
|
||||
++x;
|
||||
++y;
|
||||
}
|
||||
|
||||
path[(size_t)k + offset] = static_cast<long long>(pathCordinates.size());
|
||||
if (!editDistanceOnly) {
|
||||
P p;
|
||||
p.x = x;p.y = y;p.k = r;
|
||||
p.x = x;
|
||||
p.y = y;
|
||||
p.k = r;
|
||||
pathCordinates.push_back(p);
|
||||
}
|
||||
return y;
|
||||
@ -632,10 +610,12 @@ namespace dtl {
|
||||
++py_idx;
|
||||
}
|
||||
}
|
||||
if (i == 0) complete = true;
|
||||
if (i == 0)
|
||||
complete = true;
|
||||
}
|
||||
|
||||
if (x_idx > static_cast<long long>(M) && y_idx > static_cast<long long>(N)) {
|
||||
if (x_idx > static_cast<long long>(M) &&
|
||||
y_idx > static_cast<long long>(N)) {
|
||||
// all recording succeeded
|
||||
} else {
|
||||
// trivial difference
|
||||
@ -673,7 +653,8 @@ namespace dtl {
|
||||
/**
|
||||
* record odd sequence in SES
|
||||
*/
|
||||
void inline recordOddSequence (long long idx, long long length, sequence_const_iter it, const edit_t et) {
|
||||
void inline recordOddSequence(long long idx, long long length,
|
||||
sequence_const_iter it, const edit_t et) {
|
||||
while (idx < length) {
|
||||
ses.addSequence(*it, idx, 0, et);
|
||||
++it;
|
||||
@ -698,11 +679,8 @@ namespace dtl {
|
||||
/**
|
||||
* check if the sequences have been swapped
|
||||
*/
|
||||
bool inline wasSwapped () const {
|
||||
return swapped;
|
||||
}
|
||||
|
||||
bool inline wasSwapped() const { return swapped; }
|
||||
};
|
||||
}
|
||||
} // namespace dtl
|
||||
|
||||
#endif // DTL_DIFF_H
|
||||
|
@ -6,8 +6,8 @@
|
||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
@ -44,12 +44,11 @@ namespace dtl {
|
||||
* diff3 class template
|
||||
* sequence must support random_access_iterator.
|
||||
*/
|
||||
template <typename elem, typename sequence = vector< elem >, typename comparator = Compare< elem > >
|
||||
class Diff3
|
||||
{
|
||||
template <typename elem, typename sequence = vector<elem>,
|
||||
typename comparator = Compare<elem>>
|
||||
class Diff3 {
|
||||
private:
|
||||
dtl_typedefs(elem, sequence)
|
||||
sequence A;
|
||||
dtl_typedefs(elem, sequence) sequence A;
|
||||
sequence B;
|
||||
sequence C;
|
||||
sequence S;
|
||||
@ -59,23 +58,17 @@ namespace dtl {
|
||||
elem csepabegin;
|
||||
elem csepa;
|
||||
elem csepaend;
|
||||
|
||||
public:
|
||||
Diff3() {}
|
||||
Diff3 (const sequence& a,
|
||||
const sequence& b,
|
||||
const sequence& c) : A(a), B(b), C(c),
|
||||
diff_ba(b, a), diff_bc(b, c),
|
||||
conflict(false) {}
|
||||
Diff3(const sequence &a, const sequence &b, const sequence &c)
|
||||
: A(a), B(b), C(c), diff_ba(b, a), diff_bc(b, c), conflict(false) {}
|
||||
|
||||
~Diff3() {}
|
||||
|
||||
bool isConflict () const {
|
||||
return conflict;
|
||||
}
|
||||
bool isConflict() const { return conflict; }
|
||||
|
||||
sequence getMergedSequence () const {
|
||||
return S;
|
||||
}
|
||||
sequence getMergedSequence() const { return S; }
|
||||
|
||||
/**
|
||||
* merge changes B and C into A
|
||||
@ -127,23 +120,24 @@ namespace dtl {
|
||||
|
||||
while (!isEnd(ba_end, ba_it) || !isEnd(bc_end, bc_it)) {
|
||||
while (true) {
|
||||
if (!isEnd(ba_end, ba_it) &&
|
||||
!isEnd(bc_end, bc_it) &&
|
||||
ba_it->first == bc_it->first &&
|
||||
ba_it->second.type == SES_COMMON &&
|
||||
if (!isEnd(ba_end, ba_it) && !isEnd(bc_end, bc_it) &&
|
||||
ba_it->first == bc_it->first && ba_it->second.type == SES_COMMON &&
|
||||
bc_it->second.type == SES_COMMON) {
|
||||
// do nothing
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (!isEnd(ba_end, ba_it)) seq.push_back(ba_it->first);
|
||||
else if (!isEnd(bc_end, bc_it)) seq.push_back(bc_it->first);
|
||||
if (!isEnd(ba_end, ba_it))
|
||||
seq.push_back(ba_it->first);
|
||||
else if (!isEnd(bc_end, bc_it))
|
||||
seq.push_back(bc_it->first);
|
||||
forwardUntilEnd(ba_end, ba_it);
|
||||
forwardUntilEnd(bc_end, bc_it);
|
||||
}
|
||||
if (isEnd(ba_end, ba_it) || isEnd(bc_end, bc_it)) break;
|
||||
if ( ba_it->second.type == SES_COMMON
|
||||
&& bc_it->second.type == SES_DELETE) {
|
||||
if (isEnd(ba_end, ba_it) || isEnd(bc_end, bc_it))
|
||||
break;
|
||||
if (ba_it->second.type == SES_COMMON &&
|
||||
bc_it->second.type == SES_DELETE) {
|
||||
forwardUntilEnd(ba_end, ba_it);
|
||||
forwardUntilEnd(bc_end, bc_it);
|
||||
} else if (ba_it->second.type == SES_COMMON &&
|
||||
@ -226,20 +220,22 @@ namespace dtl {
|
||||
*/
|
||||
template <typename T_iter>
|
||||
void inline forwardUntilEnd(const T_iter &end, T_iter &it) const {
|
||||
if (!isEnd(end, it)) ++it;
|
||||
if (!isEnd(end, it))
|
||||
++it;
|
||||
}
|
||||
|
||||
/**
|
||||
* add elements whose SES's type is ADD
|
||||
*/
|
||||
void inline addDecentSequence (const sesElemVec_iter& end, sesElemVec_iter& it, elemVec& seq) const {
|
||||
void inline addDecentSequence(const sesElemVec_iter &end, sesElemVec_iter &it,
|
||||
elemVec &seq) const {
|
||||
while (!isEnd(end, it)) {
|
||||
if (it->second.type == SES_ADD) seq.push_back(it->first);
|
||||
if (it->second.type == SES_ADD)
|
||||
seq.push_back(it->first);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
} // namespace dtl
|
||||
|
||||
#endif // DTL_DIFF3_H
|
||||
|
10
dtl/Lcs.hpp
10
dtl/Lcs.hpp
@ -6,8 +6,8 @@
|
||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
@ -43,13 +43,11 @@ namespace dtl {
|
||||
/**
|
||||
* Longest Common Subsequence template class
|
||||
*/
|
||||
template <typename elem>
|
||||
class Lcs : public Sequence< elem >
|
||||
{
|
||||
template <typename elem> class Lcs : public Sequence<elem> {
|
||||
public:
|
||||
Lcs() {}
|
||||
~Lcs() {}
|
||||
};
|
||||
}
|
||||
} // namespace dtl
|
||||
|
||||
#endif // DTL_LCS_H
|
||||
|
@ -6,8 +6,8 @@
|
||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
@ -43,23 +43,18 @@ namespace dtl {
|
||||
/**
|
||||
* sequence class template
|
||||
*/
|
||||
template <typename elem>
|
||||
class Sequence
|
||||
{
|
||||
template <typename elem> class Sequence {
|
||||
public:
|
||||
typedef vector<elem> elemVec;
|
||||
Sequence() {}
|
||||
virtual ~Sequence() {}
|
||||
|
||||
elemVec getSequence () const {
|
||||
return sequence;
|
||||
}
|
||||
void addSequence (elem e) {
|
||||
sequence.push_back(e);
|
||||
}
|
||||
elemVec getSequence() const { return sequence; }
|
||||
void addSequence(elem e) { sequence.push_back(e); }
|
||||
|
||||
protected:
|
||||
elemVec sequence;
|
||||
};
|
||||
}
|
||||
} // namespace dtl
|
||||
|
||||
#endif // DTL_SEQUENCE_H
|
||||
|
39
dtl/Ses.hpp
39
dtl/Ses.hpp
@ -6,8 +6,8 @@
|
||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
@ -43,44 +43,36 @@ namespace dtl {
|
||||
/**
|
||||
* Shortest Edit Script template class
|
||||
*/
|
||||
template <typename elem>
|
||||
class Ses : public Sequence< elem >
|
||||
{
|
||||
template <typename elem> class Ses : public Sequence<elem> {
|
||||
private:
|
||||
typedef pair<elem, elemInfo> sesElem;
|
||||
typedef vector<sesElem> sesElemVec;
|
||||
public :
|
||||
|
||||
public:
|
||||
Ses() : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(false) {
|
||||
nextDeleteIdx = 0;
|
||||
}
|
||||
Ses (bool moveDel) : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(moveDel) {
|
||||
Ses(bool moveDel)
|
||||
: onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(moveDel) {
|
||||
nextDeleteIdx = 0;
|
||||
}
|
||||
~Ses() {}
|
||||
|
||||
bool isOnlyAdd () const {
|
||||
return onlyAdd;
|
||||
}
|
||||
bool isOnlyAdd() const { return onlyAdd; }
|
||||
|
||||
bool isOnlyDelete () const {
|
||||
return onlyDelete;
|
||||
}
|
||||
bool isOnlyDelete() const { return onlyDelete; }
|
||||
|
||||
bool isOnlyCopy () const {
|
||||
return onlyCopy;
|
||||
}
|
||||
bool isOnlyCopy() const { return onlyCopy; }
|
||||
|
||||
bool isOnlyOneOperation() const {
|
||||
return isOnlyAdd() || isOnlyDelete() || isOnlyCopy();
|
||||
}
|
||||
|
||||
bool isChange () const {
|
||||
return !onlyCopy;
|
||||
}
|
||||
bool isChange() const { return !onlyCopy; }
|
||||
|
||||
using Sequence<elem>::addSequence;
|
||||
void addSequence (elem e, long long beforeIdx, long long afterIdx, const edit_t type) {
|
||||
void addSequence(elem e, long long beforeIdx, long long afterIdx,
|
||||
const edit_t type) {
|
||||
elemInfo info;
|
||||
info.beforeIdx = beforeIdx;
|
||||
info.afterIdx = afterIdx;
|
||||
@ -116,9 +108,8 @@ namespace dtl {
|
||||
}
|
||||
}
|
||||
|
||||
sesElemVec getSequence () const {
|
||||
return sequence;
|
||||
}
|
||||
sesElemVec getSequence() const { return sequence; }
|
||||
|
||||
private:
|
||||
sesElemVec sequence;
|
||||
bool onlyAdd;
|
||||
@ -127,6 +118,6 @@ namespace dtl {
|
||||
bool deletesFirst;
|
||||
size_t nextDeleteIdx;
|
||||
};
|
||||
}
|
||||
} // namespace dtl
|
||||
|
||||
#endif // DTL_SES_H
|
||||
|
14
dtl/dtl.hpp
14
dtl/dtl.hpp
@ -6,8 +6,8 @@
|
||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
@ -36,12 +36,12 @@
|
||||
#ifndef DTL_H
|
||||
#define DTL_H
|
||||
|
||||
#include "variables.hpp"
|
||||
#include "functors.hpp"
|
||||
#include "Sequence.hpp"
|
||||
#include "Lcs.hpp"
|
||||
#include "Ses.hpp"
|
||||
#include "Diff.hpp"
|
||||
#include "Diff3.hpp"
|
||||
#include "Lcs.hpp"
|
||||
#include "Sequence.hpp"
|
||||
#include "Ses.hpp"
|
||||
#include "functors.hpp"
|
||||
#include "variables.hpp"
|
||||
|
||||
#endif // DTL_H
|
||||
|
@ -6,8 +6,8 @@
|
||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
@ -43,14 +43,13 @@ namespace dtl {
|
||||
/**
|
||||
* printer class template
|
||||
*/
|
||||
template <typename sesElem, typename stream = ostream >
|
||||
class Printer
|
||||
{
|
||||
template <typename sesElem, typename stream = ostream> class Printer {
|
||||
public:
|
||||
Printer() : out_(cout) {}
|
||||
Printer(stream &out) : out_(out) {}
|
||||
virtual ~Printer() {}
|
||||
virtual void operator()(const sesElem &se) const = 0;
|
||||
|
||||
protected:
|
||||
stream &out_;
|
||||
};
|
||||
@ -59,8 +58,7 @@ namespace dtl {
|
||||
* common element printer class template
|
||||
*/
|
||||
template <typename sesElem, typename stream = ostream>
|
||||
class CommonPrinter : public Printer < sesElem, stream >
|
||||
{
|
||||
class CommonPrinter : public Printer<sesElem, stream> {
|
||||
public:
|
||||
CommonPrinter() : Printer<sesElem, stream>() {}
|
||||
CommonPrinter(stream &out) : Printer<sesElem, stream>(out) {}
|
||||
@ -74,8 +72,7 @@ namespace dtl {
|
||||
* ses element printer class template
|
||||
*/
|
||||
template <typename sesElem, typename stream = ostream>
|
||||
class ChangePrinter : public Printer < sesElem, stream >
|
||||
{
|
||||
class ChangePrinter : public Printer<sesElem, stream> {
|
||||
public:
|
||||
ChangePrinter() : Printer<sesElem, stream>() {}
|
||||
ChangePrinter(stream &out) : Printer<sesElem, stream>(out) {}
|
||||
@ -98,23 +95,24 @@ namespace dtl {
|
||||
/**
|
||||
* unified format element printer class template
|
||||
*/
|
||||
template <typename sesElem, typename stream = ostream >
|
||||
class UniHunkPrinter
|
||||
{
|
||||
template <typename sesElem, typename stream = ostream> class UniHunkPrinter {
|
||||
public:
|
||||
UniHunkPrinter() : out_(cout) {}
|
||||
UniHunkPrinter(stream &out) : out_(out) {}
|
||||
~UniHunkPrinter() {}
|
||||
void operator()(const uniHunk<sesElem> &hunk) const {
|
||||
out_ << "@@"
|
||||
<< " -" << hunk.a << "," << hunk.b
|
||||
<< " +" << hunk.c << "," << hunk.d
|
||||
<< " -" << hunk.a << "," << hunk.b << " +" << hunk.c << "," << hunk.d
|
||||
<< " @@" << endl;
|
||||
|
||||
for_each(hunk.common[0].begin(), hunk.common[0].end(), CommonPrinter< sesElem, stream >(out_));
|
||||
for_each(hunk.change.begin(), hunk.change.end(), ChangePrinter< sesElem, stream >(out_));
|
||||
for_each(hunk.common[1].begin(), hunk.common[1].end(), CommonPrinter< sesElem, stream >(out_));
|
||||
for_each(hunk.common[0].begin(), hunk.common[0].end(),
|
||||
CommonPrinter<sesElem, stream>(out_));
|
||||
for_each(hunk.change.begin(), hunk.change.end(),
|
||||
ChangePrinter<sesElem, stream>(out_));
|
||||
for_each(hunk.common[1].begin(), hunk.common[1].end(),
|
||||
CommonPrinter<sesElem, stream>(out_));
|
||||
}
|
||||
|
||||
private:
|
||||
stream &out_;
|
||||
};
|
||||
@ -122,13 +120,12 @@ namespace dtl {
|
||||
/**
|
||||
* storage class template
|
||||
*/
|
||||
template <typename sesElem, typename storedData >
|
||||
class Storage
|
||||
{
|
||||
template <typename sesElem, typename storedData> class Storage {
|
||||
public:
|
||||
Storage(storedData &sd) : storedData_(sd) {}
|
||||
virtual ~Storage() {}
|
||||
virtual void operator()(const sesElem &se) const = 0;
|
||||
|
||||
protected:
|
||||
storedData &storedData_;
|
||||
};
|
||||
@ -136,9 +133,7 @@ namespace dtl {
|
||||
/**
|
||||
* compare class template
|
||||
*/
|
||||
template <typename elem>
|
||||
class Compare
|
||||
{
|
||||
template <typename elem> class Compare {
|
||||
public:
|
||||
Compare() {}
|
||||
virtual ~Compare() {}
|
||||
@ -146,6 +141,6 @@ namespace dtl {
|
||||
return e1 == e2;
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace dtl
|
||||
|
||||
#endif // DTL_FUNCTORS_H
|
||||
|
@ -6,8 +6,8 @@
|
||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
@ -38,32 +38,32 @@
|
||||
#ifndef DTL_VARIABLES_H
|
||||
#define DTL_VARIABLES_H
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace dtl {
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::pair;
|
||||
using std::ostream;
|
||||
using std::list;
|
||||
using std::for_each;
|
||||
using std::distance;
|
||||
using std::fill;
|
||||
using std::cout;
|
||||
using std::distance;
|
||||
using std::endl;
|
||||
using std::rotate;
|
||||
using std::swap;
|
||||
using std::fill;
|
||||
using std::for_each;
|
||||
using std::list;
|
||||
using std::max;
|
||||
using std::ostream;
|
||||
using std::pair;
|
||||
using std::rotate;
|
||||
using std::string;
|
||||
using std::swap;
|
||||
using std::vector;
|
||||
|
||||
/**
|
||||
* version string
|
||||
*/
|
||||
const string version = "1.20";
|
||||
const string version = "1.21";
|
||||
|
||||
/**
|
||||
* type of edit for SES
|
||||
@ -88,7 +88,8 @@ namespace dtl {
|
||||
long long afterIdx; // index of after sequence
|
||||
edit_t type; // type of edit(Add, Delete, Common)
|
||||
bool operator==(const eleminfo &other) const {
|
||||
return (this->beforeIdx == other.beforeIdx && this->afterIdx == other.afterIdx && this->type == other.type);
|
||||
return (this->beforeIdx == other.beforeIdx &&
|
||||
this->afterIdx == other.afterIdx && this->type == other.type);
|
||||
}
|
||||
} elemInfo;
|
||||
|
||||
@ -115,8 +116,7 @@ namespace dtl {
|
||||
/**
|
||||
* Structure of Unified Format Hunk
|
||||
*/
|
||||
template <typename sesElem>
|
||||
struct uniHunk {
|
||||
template <typename sesElem> struct uniHunk {
|
||||
long long a, b, c, d; // @@ -a,b +c,d @@
|
||||
vector<sesElem> common[2]; // anteroposterior commons on changes
|
||||
vector<sesElem> change; // changes
|
||||
@ -136,7 +136,6 @@ namespace dtl {
|
||||
typedef typename sequence::const_iterator sequence_const_iter; \
|
||||
typedef typename elemVec::iterator elemVec_iter;
|
||||
|
||||
|
||||
}
|
||||
} // namespace dtl
|
||||
|
||||
#endif // DTL_VARIABLES_H
|
||||
|
@ -1,14 +1,14 @@
|
||||
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <dtl/dtl.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <vector>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif // HAVE_UNISTD_H
|
||||
@ -21,8 +21,7 @@ typedef unsigned char elem;
|
||||
typedef vector<elem> sequence;
|
||||
|
||||
static int create_byte_seq(const char *fs, sequence &seq);
|
||||
static int create_byte_seq(const char *fs, sequence& seq)
|
||||
{
|
||||
static int create_byte_seq(const char *fs, sequence &seq) {
|
||||
int fd;
|
||||
int siz;
|
||||
elem buf[BUFSIZ];
|
||||
@ -44,8 +43,7 @@ static int create_byte_seq(const char *fs, sequence& seq)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (isFewArgs(argc)) {
|
||||
cerr << "Too few arguments." << endl;
|
||||
|
@ -17,4 +17,3 @@ bool isFewArgs (int argc, int limit) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
#ifndef DTL_EXAMPLE_COMMON_H
|
||||
#define DTL_EXAMPLE_COMMON_H
|
||||
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <cassert>
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <dtl/dtl.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <cassert>
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -4,8 +4,7 @@
|
||||
#include <dtl/dtl.hpp>
|
||||
|
||||
template <typename sesElem, typename stream = ostream>
|
||||
class customChangePrinter : public dtl::Printer < sesElem, stream >
|
||||
{
|
||||
class customChangePrinter : public dtl::Printer<sesElem, stream> {
|
||||
public:
|
||||
customChangePrinter() : dtl::Printer<sesElem, stream>() {}
|
||||
customChangePrinter(stream &out) : dtl::Printer<sesElem, stream>(out) {}
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <iostream>
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace dtl;
|
||||
@ -28,7 +28,8 @@ int main(int argc, char *argv[]){
|
||||
}
|
||||
|
||||
ifstream fs(s.c_str());
|
||||
const Ses< elem > ses = Diff< elem, sequence >::composeSesFromStream< ifstream >(fs);
|
||||
const Ses<elem> ses =
|
||||
Diff<elem, sequence>::composeSesFromStream<ifstream>(fs);
|
||||
dtl::Diff<elem, sequence>::printSES(ses);
|
||||
|
||||
return 0;
|
||||
|
@ -4,8 +4,7 @@
|
||||
#include <dtl/dtl.hpp>
|
||||
|
||||
template <typename sesElem, typename storedData>
|
||||
class CustomStorage : public dtl::Storage < sesElem, storedData >
|
||||
{
|
||||
class CustomStorage : public dtl::Storage<sesElem, storedData> {
|
||||
public:
|
||||
CustomStorage(storedData &sd) : dtl::Storage<sesElem, storedData>(sd) {}
|
||||
~CustomStorage() {}
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <iostream>
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -18,8 +18,7 @@ using dtl::uniHunk;
|
||||
static void showStats(string fp1, string fp2);
|
||||
static void unifiedDiff(string fp1, string fp2);
|
||||
|
||||
static void showStats (string fp1, string fp2)
|
||||
{
|
||||
static void showStats(string fp1, string fp2) {
|
||||
const int MAX_LENGTH = 255;
|
||||
char time_format[] = "%Y-%m-%d %H:%M:%S %z";
|
||||
time_t rawtime[2];
|
||||
@ -46,8 +45,7 @@ static void showStats (string fp1, string fp2)
|
||||
cout << "+++ " << fp2 << '\t' << buf[1] << endl;
|
||||
}
|
||||
|
||||
static void unifiedDiff (string fp1, string fp2)
|
||||
{
|
||||
static void unifiedDiff(string fp1, string fp2) {
|
||||
typedef string elem;
|
||||
typedef vector<elem> sequence;
|
||||
typedef pair<elem, elemInfo> sesElem;
|
||||
@ -80,9 +78,7 @@ static void unifiedDiff (string fp1, string fp2)
|
||||
diff.printUnifiedFormat();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
if (isFewArgs(argc)) {
|
||||
cerr << "Too few arguments." << endl;
|
||||
return -1;
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#include <dtl/dtl.hpp>
|
||||
#include "common.hpp"
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
#include "dtl_test_common.hpp"
|
||||
|
||||
class Intdifftest : public ::testing::Test
|
||||
{
|
||||
class Intdifftest : public ::testing::Test {
|
||||
protected:
|
||||
dtl_test_typedefs(int, vector< int >)
|
||||
typedef struct case_t {
|
||||
dtl_test_typedefs(int, vector<int>) typedef struct case_t {
|
||||
sequence A;
|
||||
sequence B;
|
||||
size_t editdis;
|
||||
@ -31,17 +29,19 @@ protected :
|
||||
string path_lses = create_path(test_name, diff_name, TYPE_DIFF_SES);
|
||||
string path_rses = create_path(test_name, diff_name, TYPE_DIFF_SES, true);
|
||||
string path_lhunks = create_path(test_name, diff_name, TYPE_DIFF_UNI);
|
||||
string path_rhunks = create_path(test_name, diff_name, TYPE_DIFF_UNI, true);
|
||||
string path_rhunks =
|
||||
create_path(test_name, diff_name, TYPE_DIFF_UNI, true);
|
||||
|
||||
create_file< elem, sequence, Compare< elem > >(path_rses, diff, TYPE_DIFF_SES);
|
||||
create_file< elem, sequence, Compare< elem > >(path_rhunks, diff, TYPE_DIFF_UNI);
|
||||
create_file<elem, sequence, Compare<elem>>(path_rses, diff,
|
||||
TYPE_DIFF_SES);
|
||||
create_file<elem, sequence, Compare<elem>>(path_rhunks, diff,
|
||||
TYPE_DIFF_UNI);
|
||||
c.editdis_ses = cal_diff_uni(path_lses, path_rses);
|
||||
c.editdis_uni = cal_diff_uni(path_lhunks, path_rhunks);
|
||||
c.path_rses = path_rses;
|
||||
c.path_rhunks = path_rhunks;
|
||||
}
|
||||
|
||||
|
||||
c.A = a;
|
||||
c.B = b;
|
||||
c.editdis = diff.getEditDistance();
|
||||
@ -74,10 +74,7 @@ protected :
|
||||
cases.push_back(createCase(A5, B5, "diff_test4"));
|
||||
}
|
||||
|
||||
void TearDown () {
|
||||
for_each(cases.begin(), cases.end(), Remover< case_t >());
|
||||
}
|
||||
|
||||
void TearDown() { for_each(cases.begin(), cases.end(), Remover<case_t>()); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "dtl_test_common.hpp"
|
||||
#include "comparators.hpp"
|
||||
#include "dtl_test_common.hpp"
|
||||
|
||||
class Objdifftest : public ::testing::Test
|
||||
{
|
||||
class Objdifftest : public ::testing::Test {
|
||||
protected:
|
||||
dtl_test_typedefs(string, vector<elem>)
|
||||
typedef struct case_t {
|
||||
dtl_test_typedefs(string, vector<elem>) typedef struct case_t {
|
||||
sequence A;
|
||||
sequence B;
|
||||
sesElemVec expected;
|
||||
@ -16,7 +14,8 @@ protected :
|
||||
caseVec obj_diff_cases;
|
||||
|
||||
template <typename comparator>
|
||||
case_t createCase (const sequence a, const sequence b, sesElemVec ses, string test_name) {
|
||||
case_t createCase(const sequence a, const sequence b, sesElemVec ses,
|
||||
string test_name) {
|
||||
case_t c;
|
||||
elemVec lcs_v;
|
||||
string diff_name("objdiff");
|
||||
@ -47,7 +46,8 @@ protected :
|
||||
ses.addSequence("brown", 3, 0, dtl::SES_DELETE);
|
||||
ses.addSequence("Fox", 0, 3, dtl::SES_ADD);
|
||||
|
||||
obj_diff_cases.push_back(createCase< StringCaseInsensitive >(A, B, ses.getSequence(), "objdiff_test0_pattern"));
|
||||
obj_diff_cases.push_back(createCase<StringCaseInsensitive>(
|
||||
A, B, ses.getSequence(), "objdiff_test0_pattern"));
|
||||
}
|
||||
|
||||
{
|
||||
@ -67,7 +67,8 @@ protected :
|
||||
ses.addSequence("f", 0, 4, dtl::SES_ADD);
|
||||
ses.addSequence("h", 0, 5, dtl::SES_ADD);
|
||||
|
||||
obj_diff_cases.push_back(createCase< StringCaseInsensitive >(A, B, ses.getSequence(), "objdiff_test1_unswapped"));
|
||||
obj_diff_cases.push_back(createCase<StringCaseInsensitive>(
|
||||
A, B, ses.getSequence(), "objdiff_test1_unswapped"));
|
||||
}
|
||||
{
|
||||
string array1[] = {"a", "d", "e", "f", "h"};
|
||||
@ -86,16 +87,17 @@ protected :
|
||||
ses.addSequence("h", 5, 0, dtl::SES_DELETE);
|
||||
ses.addSequence("g", 0, 4, dtl::SES_ADD);
|
||||
|
||||
obj_diff_cases.push_back(createCase< StringCaseInsensitive >(A, B, ses.getSequence(), "objdiff_test2_swapped"));
|
||||
obj_diff_cases.push_back(createCase<StringCaseInsensitive>(
|
||||
A, B, ses.getSequence(), "objdiff_test2_swapped"));
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
//for_each(obj_diff_cases.begin(), obj_diff_cases.end(), Remover< case_t >());
|
||||
// for_each(obj_diff_cases.begin(), obj_diff_cases.end(), Remover< case_t
|
||||
// >());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Objdifftest
|
||||
* check list:
|
||||
|
@ -1,10 +1,8 @@
|
||||
#include "dtl_test_common.hpp"
|
||||
|
||||
class Patchtest : public ::testing::Test
|
||||
{
|
||||
class Patchtest : public ::testing::Test {
|
||||
protected:
|
||||
dtl_test_typedefs(char, string)
|
||||
typedef struct case_t {
|
||||
dtl_test_typedefs(char, string) typedef struct case_t {
|
||||
sequence A;
|
||||
sequence B;
|
||||
Diff<elem, sequence> diff;
|
||||
@ -32,14 +30,69 @@ protected :
|
||||
cases.push_back(createCase("", "")); // 5
|
||||
cases.push_back(createCase("a", "")); // 6
|
||||
cases.push_back(createCase("", "b")); // 7
|
||||
cases.push_back(createCase("abcdefq3wefarhgorequgho4euhfteowauhfwehogfewrquhoi23hroewhoahfotrhguoiewahrgqqabcdef",
|
||||
cases.push_back(createCase(
|
||||
"abcdefq3wefarhgorequgho4euhfteowauhfwehogfewrquhoi23hroewhoahfotrhguoi"
|
||||
"ewahrgqqabcdef",
|
||||
"3abcdef4976fd86ouofita67t85r876e5e746578tgliuhopoqqabcdef")); // 8
|
||||
cases.push_back(createCase("abcqqqeqqqccc", "abdqqqeqqqddd")); // 9
|
||||
cases.push_back(createCase("aaaaaaaaaaaaa>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>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&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&saaabcaaaaaaccc")); // 10
|
||||
}
|
||||
|
||||
void TearDown() {}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -3,18 +3,20 @@
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def path_chomp(path):
|
||||
if path[-1] == '/':
|
||||
return path[:-1]
|
||||
return path
|
||||
|
||||
|
||||
env = Environment(
|
||||
CPPFLAGS=['-Wall', '-O2'],
|
||||
CPPPATH=['..'],
|
||||
CXXFLAGS="-std=c++11",
|
||||
)
|
||||
|
||||
conf = Configure(env);
|
||||
conf = Configure(env)
|
||||
|
||||
if not conf.CheckCXX():
|
||||
print("c++ compiler is not installed!")
|
||||
@ -33,10 +35,6 @@ test = env.Program(
|
||||
[Glob('*.cpp')],
|
||||
)
|
||||
|
||||
test_alias = env.Alias(
|
||||
'check',
|
||||
test,
|
||||
test[0].abspath
|
||||
)
|
||||
test_alias = env.Alias('check', test, test[0].abspath)
|
||||
|
||||
env.AlwaysBuild(test_alias)
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "dtl_test_common.hpp"
|
||||
#include "comparators.hpp"
|
||||
#include "dtl_test_common.hpp"
|
||||
|
||||
class Strdiff3test : public ::testing::Test
|
||||
{
|
||||
class Strdiff3test : public ::testing::Test {
|
||||
protected:
|
||||
dtl_test_typedefs(char, string)
|
||||
typedef struct case_t {
|
||||
dtl_test_typedefs(char, string) typedef struct case_t {
|
||||
sequence S;
|
||||
bool is_merge_success;
|
||||
sequence merged_seq;
|
||||
@ -31,41 +29,67 @@ protected :
|
||||
|
||||
void SetUp() {
|
||||
// merge test
|
||||
merge_cases.push_back(createCase< Compare < elem > >("ab", "b", "bc", "abc")); // 0
|
||||
merge_cases.push_back(createCase< Compare < elem > >("bc", "b", "ab", "abc")); // 1
|
||||
merge_cases.push_back(createCase< Compare < elem > >("qqqabc", "abc", "abcdef", "qqqabcdef")); // 2
|
||||
merge_cases.push_back(createCase< Compare < elem > >("abcdef", "abc", "qqqabc", "qqqabcdef")); // 3
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aaacccbbb", "aaabbb", "aaabbbqqq", "aaacccbbbqqq")); // 4
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aaabbbqqq", "aaabbb", "aaacccbbb", "aaacccbbbqqq")); // 5
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aeaacccbbb", "aaabbb", "aaabbbqqq", "aeaacccbbbqqq")); // 6
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aaabbbqqq", "aaabbb", "aeaacccbbb", "aeaacccbbbqqq")); // 7
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aeaacccbbb", "aaabbb", "aaabebbqqq", "aeaacccbebbqqq")); // 8
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aaabebbqqq", "aaabbb", "aeaacccbbb", "aeaacccbebbqqq")); // 9
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aaacccbbb", "aaabbb", "aeaabbbqqq", "aeaacccbbbqqq")); // 10
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aeaabbbqqq", "aaabbb", "aaacccbbb", "aeaacccbbbqqq")); // 11
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aaacccbbb", "aaabbb", "aaabeebbeeqqq","aaacccbeebbeeqqq")); // 12
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aaabeebbeeqqq", "aaabbb", "aaacccbbb", "aaacccbeebbeeqqq")); // 13
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aiueo", "aeo", "aeKokaki", "aiueKokaki")); // 14
|
||||
merge_cases.push_back(createCase< Compare < elem > >("aeKokaki", "aeo", "aiueo", "aiueKokaki")); // 15
|
||||
merge_cases.push_back(createCase< Compare < elem > >("1234567390", "1234567890", "1239567890", "1239567390")); // 16
|
||||
merge_cases.push_back(createCase< Compare < elem > >("1239567890", "1234567890", "1234567390", "1239567390")); // 17
|
||||
merge_cases.push_back(createCase< Compare < elem > >("qabcdef", "abcdef", "ab", "qab")); // 18
|
||||
merge_cases.push_back(createCase< Compare < elem > >("ab", "abcdef", "qabcdef", "qab")); // 19
|
||||
merge_cases.push_back(createCase< Compare < elem > >("abcdf", "abcdef", "acdef", "acdf")); // 20
|
||||
merge_cases.push_back(createCase< Compare < elem > >("acdef", "abcdef", "abcdf", "acdf")); // 21
|
||||
merge_cases.push_back(createCase< Compare < elem > >("acdef", "abcdef", "abcdfaa", "acdfaa")); // 22
|
||||
merge_cases.push_back(createCase< Compare < elem > >("abcdfaa", "abcdef", "acdef", "acdfaa")); // 23
|
||||
merge_cases.push_back(
|
||||
createCase<Compare<elem>>("ab", "b", "bc", "abc")); // 0
|
||||
merge_cases.push_back(
|
||||
createCase<Compare<elem>>("bc", "b", "ab", "abc")); // 1
|
||||
merge_cases.push_back(
|
||||
createCase<Compare<elem>>("qqqabc", "abc", "abcdef", "qqqabcdef")); // 2
|
||||
merge_cases.push_back(
|
||||
createCase<Compare<elem>>("abcdef", "abc", "qqqabc", "qqqabcdef")); // 3
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aaacccbbb", "aaabbb", "aaabbbqqq", "aaacccbbbqqq")); // 4
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aaabbbqqq", "aaabbb", "aaacccbbb", "aaacccbbbqqq")); // 5
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aeaacccbbb", "aaabbb", "aaabbbqqq", "aeaacccbbbqqq")); // 6
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aaabbbqqq", "aaabbb", "aeaacccbbb", "aeaacccbbbqqq")); // 7
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aeaacccbbb", "aaabbb", "aaabebbqqq", "aeaacccbebbqqq")); // 8
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aaabebbqqq", "aaabbb", "aeaacccbbb", "aeaacccbebbqqq")); // 9
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aaacccbbb", "aaabbb", "aeaabbbqqq", "aeaacccbbbqqq")); // 10
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aeaabbbqqq", "aaabbb", "aaacccbbb", "aeaacccbbbqqq")); // 11
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aaacccbbb", "aaabbb", "aaabeebbeeqqq", "aaacccbeebbeeqqq")); // 12
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"aaabeebbeeqqq", "aaabbb", "aaacccbbb", "aaacccbeebbeeqqq")); // 13
|
||||
merge_cases.push_back(createCase<Compare<elem>>("aiueo", "aeo", "aeKokaki",
|
||||
"aiueKokaki")); // 14
|
||||
merge_cases.push_back(createCase<Compare<elem>>("aeKokaki", "aeo", "aiueo",
|
||||
"aiueKokaki")); // 15
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"1234567390", "1234567890", "1239567890", "1239567390")); // 16
|
||||
merge_cases.push_back(createCase<Compare<elem>>(
|
||||
"1239567890", "1234567890", "1234567390", "1239567390")); // 17
|
||||
merge_cases.push_back(
|
||||
createCase<Compare<elem>>("qabcdef", "abcdef", "ab", "qab")); // 18
|
||||
merge_cases.push_back(
|
||||
createCase<Compare<elem>>("ab", "abcdef", "qabcdef", "qab")); // 19
|
||||
merge_cases.push_back(
|
||||
createCase<Compare<elem>>("abcdf", "abcdef", "acdef", "acdf")); // 20
|
||||
merge_cases.push_back(
|
||||
createCase<Compare<elem>>("acdef", "abcdef", "abcdf", "acdf")); // 21
|
||||
merge_cases.push_back(createCase<Compare<elem>>("acdef", "abcdef",
|
||||
"abcdfaa", "acdfaa")); // 22
|
||||
merge_cases.push_back(createCase<Compare<elem>>("abcdfaa", "abcdef",
|
||||
"acdef", "acdfaa")); // 23
|
||||
|
||||
// detect confliction test
|
||||
detect_cases.push_back(createCase< Compare < elem > >("adc", "abc", "aec", "")); // 0
|
||||
detect_cases.push_back(createCase< Compare < elem > >("abqdcf", "abcdef", "abqqef", "")); // 1
|
||||
detect_cases.push_back(
|
||||
createCase<Compare<elem>>("adc", "abc", "aec", "")); // 0
|
||||
detect_cases.push_back(
|
||||
createCase<Compare<elem>>("abqdcf", "abcdef", "abqqef", "")); // 1
|
||||
|
||||
// use custom comparator
|
||||
custom_cases.push_back(createCase< CaseInsensitive >("abc", "abc", "abC", "abc"));
|
||||
custom_cases.push_back(
|
||||
createCase<CaseInsensitive>("abc", "abc", "abC", "abc"));
|
||||
}
|
||||
|
||||
void TearDown() {}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "dtl_test_common.hpp"
|
||||
#include "comparators.hpp"
|
||||
#include "dtl_test_common.hpp"
|
||||
|
||||
class Strdifftest : public ::testing::Test
|
||||
{
|
||||
class Strdifftest : public ::testing::Test {
|
||||
protected:
|
||||
dtl_test_typedefs(char, string)
|
||||
typedef struct case_t {
|
||||
dtl_test_typedefs(char, string) typedef struct case_t {
|
||||
sequence A;
|
||||
sequence B;
|
||||
size_t editdis;
|
||||
@ -25,7 +23,8 @@ protected :
|
||||
caseVec custom_cases;
|
||||
|
||||
template <typename comparator>
|
||||
case_t createCase (const sequence a, const sequence b, string test_name, bool onlyEditdis = false) {
|
||||
case_t createCase(const sequence a, const sequence b, string test_name,
|
||||
bool onlyEditdis = false) {
|
||||
case_t c;
|
||||
elemVec lcs_v;
|
||||
string diff_name("strdiff");
|
||||
@ -43,7 +42,8 @@ protected :
|
||||
string path_lses = create_path(test_name, diff_name, TYPE_DIFF_SES);
|
||||
string path_rses = create_path(test_name, diff_name, TYPE_DIFF_SES, true);
|
||||
string path_lhunks = create_path(test_name, diff_name, TYPE_DIFF_UNI);
|
||||
string path_rhunks = create_path(test_name, diff_name, TYPE_DIFF_UNI, true);
|
||||
string path_rhunks =
|
||||
create_path(test_name, diff_name, TYPE_DIFF_UNI, true);
|
||||
diff_resultset_exist_check(path_lses);
|
||||
diff_resultset_exist_check(path_lhunks);
|
||||
|
||||
@ -68,26 +68,38 @@ protected :
|
||||
|
||||
void SetUp(void) {
|
||||
diff_cases.push_back(createCase<Compare<elem>>("abc", "abd", "diff_test0"));
|
||||
diff_cases.push_back(createCase< Compare< elem > >("acbdeacbed", "acebdabbabed", "diff_test1"));
|
||||
diff_cases.push_back(createCase< Compare< elem > >("abcdef", "dacfea", "diff_test2"));
|
||||
diff_cases.push_back(createCase< Compare< elem > >("abcbda", "bdcaba", "diff_test3"));
|
||||
diff_cases.push_back(createCase< Compare< elem > >("bokko", "bokkko", "diff_test4"));
|
||||
diff_cases.push_back(
|
||||
createCase<Compare<elem>>("acbdeacbed", "acebdabbabed", "diff_test1"));
|
||||
diff_cases.push_back(
|
||||
createCase<Compare<elem>>("abcdef", "dacfea", "diff_test2"));
|
||||
diff_cases.push_back(
|
||||
createCase<Compare<elem>>("abcbda", "bdcaba", "diff_test3"));
|
||||
diff_cases.push_back(
|
||||
createCase<Compare<elem>>("bokko", "bokkko", "diff_test4"));
|
||||
diff_cases.push_back(createCase<Compare<elem>>("", "", "diff_test5"));
|
||||
diff_cases.push_back(createCase<Compare<elem>>("a", "", "diff_test6"));
|
||||
diff_cases.push_back(createCase<Compare<elem>>("", "b", "diff_test7"));
|
||||
diff_cases.push_back(createCase< Compare< elem > >("acbdeaqqqqqqqcbed", "acebdabbqqqqqqqabed", "diff_test8"));
|
||||
diff_cases.push_back(createCase<Compare<elem>>(
|
||||
"acbdeaqqqqqqqcbed", "acebdabbqqqqqqqabed", "diff_test8"));
|
||||
|
||||
only_editdis_cases.push_back(createCase< Compare< elem > >("abc", "abd", "", true));
|
||||
only_editdis_cases.push_back(createCase< Compare< elem > >("acbdeacbed", "acebdabbabed", "", true));
|
||||
only_editdis_cases.push_back(createCase< Compare< elem > >("abcdef", "dacfea", "", true));
|
||||
only_editdis_cases.push_back(createCase< Compare< elem > >("abcbda", "bdcaba", "", true));
|
||||
only_editdis_cases.push_back(createCase< Compare< elem > >("bokko", "bokkko", "", true));
|
||||
only_editdis_cases.push_back(
|
||||
createCase<Compare<elem>>("abc", "abd", "", true));
|
||||
only_editdis_cases.push_back(
|
||||
createCase<Compare<elem>>("acbdeacbed", "acebdabbabed", "", true));
|
||||
only_editdis_cases.push_back(
|
||||
createCase<Compare<elem>>("abcdef", "dacfea", "", true));
|
||||
only_editdis_cases.push_back(
|
||||
createCase<Compare<elem>>("abcbda", "bdcaba", "", true));
|
||||
only_editdis_cases.push_back(
|
||||
createCase<Compare<elem>>("bokko", "bokkko", "", true));
|
||||
only_editdis_cases.push_back(createCase<Compare<elem>>("", "", "", true));
|
||||
only_editdis_cases.push_back(createCase<Compare<elem>>("a", "", "", true));
|
||||
only_editdis_cases.push_back(createCase<Compare<elem>>("", "b", "", true));
|
||||
only_editdis_cases.push_back(createCase< Compare< elem > >("acbdeaqqqqqqqcbed", "acebdabbqqqqqqqabed", "", true));
|
||||
only_editdis_cases.push_back(createCase<Compare<elem>>(
|
||||
"acbdeaqqqqqqqcbed", "acebdabbqqqqqqqabed", "", true));
|
||||
|
||||
custom_cases.push_back(createCase< CaseInsensitive >("abc", "Abc", "custom_test0"));
|
||||
custom_cases.push_back(
|
||||
createCase<CaseInsensitive>("abc", "Abc", "custom_test0"));
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
@ -96,7 +108,6 @@ protected :
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Strdifftest
|
||||
* check list is following
|
||||
|
@ -14,8 +14,7 @@ public:
|
||||
if (a.length() == b.length()) {
|
||||
bool equal = (strncasecmp(a.c_str(), b.c_str(), a.length()) == 0);
|
||||
return equal;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
|
||||
#include "dtl_test_common.hpp"
|
||||
|
||||
string create_path (const string& test_name, string diff_name, enum type_diff t, bool is_use_suffix) {
|
||||
string create_path(const string &test_name, string diff_name, enum type_diff t,
|
||||
bool is_use_suffix) {
|
||||
string ret;
|
||||
switch (t) {
|
||||
case TYPE_DIFF_SES:
|
||||
ret = (getcwd(NULL, 0) + string("/") + string("ses") + string("/") + diff_name + string("/") + test_name);
|
||||
ret = (getcwd(NULL, 0) + string("/") + string("ses") + string("/") +
|
||||
diff_name + string("/") + test_name);
|
||||
break;
|
||||
case TYPE_DIFF_UNI:
|
||||
ret = (getcwd(NULL, 0) + string("/") + string("hunks") + string("/") + diff_name + string("/") + test_name);
|
||||
ret = (getcwd(NULL, 0) + string("/") + string("hunks") + string("/") +
|
||||
diff_name + string("/") + test_name);
|
||||
break;
|
||||
}
|
||||
ret += is_use_suffix ? "_" : "";
|
||||
@ -47,9 +50,13 @@ bool is_file_exist (string& fs) {
|
||||
|
||||
void diff_resultset_exist_check(string &fs) {
|
||||
if (!is_file_exist(fs)) {
|
||||
cerr << "======================================================Error!!!======================================================" << endl;
|
||||
cerr << "======================================================Error!!!===="
|
||||
"=================================================="
|
||||
<< endl;
|
||||
cerr << "diff result set:" << fs << " is not found." << endl;
|
||||
cerr << "======================================================Error!!!======================================================" << endl;
|
||||
cerr << "======================================================Error!!!===="
|
||||
"=================================================="
|
||||
<< endl;
|
||||
cerr << "excute dtl_test in dtl/test!" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -2,30 +2,30 @@
|
||||
#ifndef DTL_TEST_COMMON
|
||||
#define DTL_TEST_COMMON
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <dtl/dtl.hpp>
|
||||
#include <fstream>
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
using std::ifstream;
|
||||
using std::ofstream;
|
||||
using std::pair;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
using dtl::Compare;
|
||||
using dtl::Diff;
|
||||
using dtl::Diff3;
|
||||
using dtl::Compare;
|
||||
using dtl::SES_COMMON;
|
||||
using dtl::SES_ADD;
|
||||
using dtl::SES_DELETE;
|
||||
using dtl::elemInfo;
|
||||
using dtl::SES_ADD;
|
||||
using dtl::SES_COMMON;
|
||||
using dtl::SES_DELETE;
|
||||
using dtl::uniHunk;
|
||||
|
||||
#define dtl_test_typedefs(e_type, seq_type) \
|
||||
@ -38,13 +38,13 @@ using dtl::uniHunk;
|
||||
|
||||
enum type_diff { TYPE_DIFF_SES, TYPE_DIFF_UNI };
|
||||
|
||||
string create_path (const string& test_name, string diff_name, enum type_diff t, bool is_use_suffix = false);
|
||||
string create_path(const string &test_name, string diff_name, enum type_diff t,
|
||||
bool is_use_suffix = false);
|
||||
size_t cal_diff_uni(const string &path_l, const string &path_r);
|
||||
bool is_file_exist(string &fs);
|
||||
void diff_resultset_exist_check(string &fs);
|
||||
|
||||
template <typename T>
|
||||
class Remover {
|
||||
template <typename T> class Remover {
|
||||
public:
|
||||
void operator()(const T &v) {
|
||||
remove(v.path_rses.c_str());
|
||||
@ -53,7 +53,8 @@ public :
|
||||
};
|
||||
|
||||
template <typename elem, typename sequence, typename comparator>
|
||||
void create_file (const string& path, Diff< elem, sequence, comparator >& diff, enum type_diff t) {
|
||||
void create_file(const string &path, Diff<elem, sequence, comparator> &diff,
|
||||
enum type_diff t) {
|
||||
ofstream ofs;
|
||||
ofs.open(path.c_str());
|
||||
switch (t) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user