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>
|
2022-04-11 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||||
|
|
||||||
* bugfix: fixed invalid offset in unified format difference when difference is too large.
|
* 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>
|
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without
|
||||||
are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
@ -44,12 +44,11 @@ namespace dtl {
|
|||||||
* diff class template
|
* diff class template
|
||||||
* sequence must support random_access_iterator.
|
* sequence must support random_access_iterator.
|
||||||
*/
|
*/
|
||||||
template <typename elem, typename sequence = vector< elem >, typename comparator = Compare< elem > >
|
template <typename elem, typename sequence = vector<elem>,
|
||||||
class Diff
|
typename comparator = Compare<elem>>
|
||||||
{
|
class Diff {
|
||||||
private:
|
private:
|
||||||
dtl_typedefs(elem, sequence)
|
dtl_typedefs(elem, sequence) sequence A;
|
||||||
sequence A;
|
|
||||||
sequence B;
|
sequence B;
|
||||||
size_t M;
|
size_t M;
|
||||||
size_t N;
|
size_t N;
|
||||||
@ -69,112 +68,71 @@ namespace dtl {
|
|||||||
comparator cmp;
|
comparator cmp;
|
||||||
long long ox;
|
long long ox;
|
||||||
long long oy;
|
long long oy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Diff() {}
|
Diff() {}
|
||||||
|
|
||||||
Diff (const sequence& a,
|
Diff(const sequence &a, const sequence &b) : A(a), B(b), ses(false) {
|
||||||
const sequence& b) : A(a), B(b), ses(false) {
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Diff (const sequence& a,
|
Diff(const sequence &a, const sequence &b, bool deletesFirst)
|
||||||
const sequence& b,
|
: A(a), B(b), ses(deletesFirst) {
|
||||||
bool deletesFirst) : A(a), B(b), ses(deletesFirst) {
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Diff (const sequence& a,
|
Diff(const sequence &a, const sequence &b, const comparator &comp)
|
||||||
const sequence& b,
|
: A(a), B(b), ses(false), cmp(comp) {
|
||||||
const comparator& comp) : A(a), B(b), ses(false), cmp(comp) {
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Diff (const sequence& a,
|
Diff(const sequence &a, const sequence &b, bool deleteFirst,
|
||||||
const sequence& b,
|
const comparator &comp)
|
||||||
bool deleteFirst,
|
: A(a), B(b), ses(deleteFirst), cmp(comp) {
|
||||||
const comparator& comp) : A(a), B(b), ses(deleteFirst), cmp(comp) {
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
~Diff() {}
|
~Diff() {}
|
||||||
|
|
||||||
long long getEditDistance () const {
|
long long getEditDistance() const { return editDistance; }
|
||||||
return editDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
Lcs< elem > getLcs () const {
|
Lcs<elem> getLcs() const { return lcs; }
|
||||||
return lcs;
|
|
||||||
}
|
|
||||||
|
|
||||||
elemVec getLcsVec () const {
|
elemVec getLcsVec() const { return lcs.getSequence(); }
|
||||||
return lcs.getSequence();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ses< elem > getSes () const {
|
Ses<elem> getSes() const { return ses; }
|
||||||
return ses;
|
|
||||||
}
|
|
||||||
|
|
||||||
uniHunkVec getUniHunks () const {
|
uniHunkVec getUniHunks() const { return uniHunks; }
|
||||||
return uniHunks;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* These should be deprecated */
|
/* These should be deprecated */
|
||||||
bool isHuge () const {
|
bool isHuge() const { return huge; }
|
||||||
return huge;
|
|
||||||
}
|
|
||||||
|
|
||||||
void onHuge () {
|
void onHuge() { this->huge = true; }
|
||||||
this->huge = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void offHuge () {
|
void offHuge() { this->huge = false; }
|
||||||
this->huge = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isUnserious () const {
|
bool isUnserious() const { return trivial; }
|
||||||
return trivial;
|
|
||||||
}
|
|
||||||
|
|
||||||
void onUnserious () {
|
void onUnserious() { this->trivial = true; }
|
||||||
this->trivial = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void offUnserious () {
|
void offUnserious() { this->trivial = false; }
|
||||||
this->trivial = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void onOnlyEditDistance () {
|
void onOnlyEditDistance() { this->editDistanceOnly = true; }
|
||||||
this->editDistanceOnly = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* These are the replacements for the above */
|
/* These are the replacements for the above */
|
||||||
bool hugeEnabled () const {
|
bool hugeEnabled() const { return huge; }
|
||||||
return huge;
|
|
||||||
}
|
|
||||||
|
|
||||||
void enableHuge () {
|
void enableHuge() { this->huge = true; }
|
||||||
this->huge = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void disableHuge () {
|
void disableHuge() { this->huge = false; }
|
||||||
this->huge = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool trivialEnabled () const {
|
bool trivialEnabled() const { return trivial; }
|
||||||
return trivial;
|
|
||||||
}
|
|
||||||
|
|
||||||
void enableTrivial () {
|
void enableTrivial() { this->trivial = true; }
|
||||||
this->trivial = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void disableTrivial () {
|
void disableTrivial() { this->trivial = false; }
|
||||||
this->trivial = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void editDistanceOnlyEnabled () {
|
void editDistanceOnlyEnabled() { this->editDistanceOnly = true; }
|
||||||
this->editDistanceOnly = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* patching with Unified Format Hunks
|
* patching with Unified Format Hunks
|
||||||
@ -232,7 +190,8 @@ namespace dtl {
|
|||||||
sesElemVec sesSeq = ses.getSequence();
|
sesElemVec sesSeq = ses.getSequence();
|
||||||
elemList seqLst(seq.begin(), seq.end());
|
elemList seqLst(seq.begin(), seq.end());
|
||||||
elemList_iter lstIt = seqLst.begin();
|
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) {
|
switch (sesIt->second.type) {
|
||||||
case SES_ADD:
|
case SES_ADD:
|
||||||
seqLst.insert(lstIt, sesIt->first);
|
seqLst.insert(lstIt, sesIt->first);
|
||||||
@ -254,8 +213,8 @@ namespace dtl {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* compose Longest Common Subsequence and Shortest Edit Script.
|
* compose Longest Common Subsequence and Shortest Edit Script.
|
||||||
* The algorithm implemented here is based on "An O(NP) Sequence Comparison Algorithm"
|
* The algorithm implemented here is based on "An O(NP) Sequence Comparison
|
||||||
* described by Sun Wu, Udi Manber and Gene Myers
|
* Algorithm" described by Sun Wu, Udi Manber and Gene Myers
|
||||||
*/
|
*/
|
||||||
void compose() {
|
void compose() {
|
||||||
|
|
||||||
@ -275,11 +234,15 @@ namespace dtl {
|
|||||||
for (long long k = -p; k <= static_cast<long long>(delta) - 1; ++k) {
|
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]);
|
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[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]);
|
fp[delta + offset] =
|
||||||
} while (fp[delta+offset] != static_cast<long long>(N) && pathCordinates.size() < MAX_CORDINATES_SIZE);
|
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;
|
editDistance += static_cast<long long>(delta) + 2 * p;
|
||||||
long long r = path[delta + offset];
|
long long r = path[delta + offset];
|
||||||
@ -312,15 +275,12 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* print difference between A and B as an SES
|
* print difference between A and B as an SES
|
||||||
*/
|
*/
|
||||||
template < typename stream >
|
template <typename stream> void printSES(stream &out) const {
|
||||||
void printSES (stream& out) const {
|
|
||||||
sesElemVec ses_v = ses.getSequence();
|
sesElemVec ses_v = ses.getSequence();
|
||||||
for_each(ses_v.begin(), ses_v.end(), ChangePrinter<sesElem, stream>(out));
|
for_each(ses_v.begin(), ses_v.end(), ChangePrinter<sesElem, stream>(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
void printSES (ostream& out = cout) const {
|
void printSES(ostream &out = cout) const { printSES<ostream>(out); }
|
||||||
printSES< ostream >(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print differences given an SES
|
* print differences given an SES
|
||||||
@ -347,7 +307,8 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* store difference between A and B as an SES with custom storage
|
* 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 {
|
void storeSES(storedData &sd) const {
|
||||||
sesElemVec ses_v = ses.getSequence();
|
sesElemVec ses_v = ses.getSequence();
|
||||||
for_each(ses_v.begin(), ses_v.end(), ST<sesElem, storedData>(sd));
|
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
|
* print difference between A and B in the Unified Format
|
||||||
*/
|
*/
|
||||||
template < typename stream >
|
template <typename stream> void printUnifiedFormat(stream &out) const {
|
||||||
void printUnifiedFormat (stream& out) const {
|
for_each(uniHunks.begin(), uniHunks.end(),
|
||||||
for_each(uniHunks.begin(), uniHunks.end(), UniHunkPrinter< sesElem, stream >(out));
|
UniHunkPrinter<sesElem, stream>(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
void printUnifiedFormat(ostream &out = cout) const {
|
void printUnifiedFormat(ostream &out = cout) const {
|
||||||
@ -405,8 +366,10 @@ namespace dtl {
|
|||||||
middle = 0;
|
middle = 0;
|
||||||
++inc_dec_count;
|
++inc_dec_count;
|
||||||
adds.push_back(*it);
|
adds.push_back(*it);
|
||||||
if (!isMiddle) isMiddle = true;
|
if (!isMiddle)
|
||||||
if (isMiddle) ++d;
|
isMiddle = true;
|
||||||
|
if (isMiddle)
|
||||||
|
++d;
|
||||||
if (l_cnt >= length) {
|
if (l_cnt >= length) {
|
||||||
joinSesVec(change, deletes);
|
joinSesVec(change, deletes);
|
||||||
joinSesVec(change, adds);
|
joinSesVec(change, adds);
|
||||||
@ -417,8 +380,10 @@ namespace dtl {
|
|||||||
middle = 0;
|
middle = 0;
|
||||||
--inc_dec_count;
|
--inc_dec_count;
|
||||||
deletes.push_back(*it);
|
deletes.push_back(*it);
|
||||||
if (!isMiddle) isMiddle = true;
|
if (!isMiddle)
|
||||||
if (isMiddle) ++b;
|
isMiddle = true;
|
||||||
|
if (isMiddle)
|
||||||
|
++b;
|
||||||
if (l_cnt >= length) {
|
if (l_cnt >= length) {
|
||||||
joinSesVec(change, deletes);
|
joinSesVec(change, deletes);
|
||||||
joinSesVec(change, adds);
|
joinSesVec(change, adds);
|
||||||
@ -426,8 +391,10 @@ namespace dtl {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SES_COMMON:
|
case SES_COMMON:
|
||||||
++b;++d;
|
++b;
|
||||||
if (common[1].empty() && adds.empty() && deletes.empty() && change.empty()) {
|
++d;
|
||||||
|
if (common[1].empty() && adds.empty() && deletes.empty() &&
|
||||||
|
change.empty()) {
|
||||||
if (static_cast<long long>(common[0].size()) < DTL_CONTEXT_SIZE) {
|
if (static_cast<long long>(common[0].size()) < DTL_CONTEXT_SIZE) {
|
||||||
if (a == 0 && c == 0) {
|
if (a == 0 && c == 0) {
|
||||||
if (!wasSwapped()) {
|
if (!wasSwapped()) {
|
||||||
@ -443,8 +410,10 @@ namespace dtl {
|
|||||||
rotate(common[0].begin(), common[0].begin() + 1, common[0].end());
|
rotate(common[0].begin(), common[0].begin() + 1, common[0].end());
|
||||||
common[0].pop_back();
|
common[0].pop_back();
|
||||||
common[0].push_back(*it);
|
common[0].push_back(*it);
|
||||||
++a;++c;
|
++a;
|
||||||
--b;--d;
|
++c;
|
||||||
|
--b;
|
||||||
|
--d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isMiddle && !isAfter) {
|
if (isMiddle && !isAfter) {
|
||||||
@ -467,7 +436,8 @@ namespace dtl {
|
|||||||
if (isAfter && !change.empty()) {
|
if (isAfter && !change.empty()) {
|
||||||
sesElemVec_iter cit = it;
|
sesElemVec_iter cit = it;
|
||||||
long long cnt = 0;
|
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) {
|
if (cit->second.type == SES_COMMON) {
|
||||||
++cnt;
|
++cnt;
|
||||||
}
|
}
|
||||||
@ -488,9 +458,12 @@ namespace dtl {
|
|||||||
a += c0size - DTL_SEPARATE_SIZE;
|
a += c0size - DTL_SEPARATE_SIZE;
|
||||||
c += c0size - DTL_SEPARATE_SIZE;
|
c += c0size - DTL_SEPARATE_SIZE;
|
||||||
}
|
}
|
||||||
if (a == 0) ++a;
|
if (a == 0)
|
||||||
if (c == 0) ++c;
|
++a;
|
||||||
if (wasSwapped()) swap(a, c);
|
if (c == 0)
|
||||||
|
++c;
|
||||||
|
if (wasSwapped())
|
||||||
|
swap(a, c);
|
||||||
hunk.a = a;
|
hunk.a = a;
|
||||||
hunk.b = b;
|
hunk.b = b;
|
||||||
hunk.c = c;
|
hunk.c = c;
|
||||||
@ -515,9 +488,7 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* compose ses from stream
|
* compose ses from stream
|
||||||
*/
|
*/
|
||||||
template <typename stream>
|
template <typename stream> static Ses<elem> composeSesFromStream(stream &st) {
|
||||||
static Ses< elem > composeSesFromStream (stream& st)
|
|
||||||
{
|
|
||||||
elem line;
|
elem line;
|
||||||
Ses<elem> ret;
|
Ses<elem> ret;
|
||||||
long long x_idx, y_idx;
|
long long x_idx, y_idx;
|
||||||
@ -568,18 +539,25 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* search shortest path and record the path
|
* search shortest path and record the path
|
||||||
*/
|
*/
|
||||||
long long snake(const long long& k, const long long& above, const long long& below) {
|
long long snake(const long long &k, const long long &above,
|
||||||
long long r = above > below ? path[(size_t)k-1+offset] : path[(size_t)k+1+offset];
|
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 y = max(above, below);
|
||||||
long long x = y - k;
|
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]))) {
|
while ((size_t)x < M && (size_t)y < N &&
|
||||||
++x;++y;
|
(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());
|
path[(size_t)k + offset] = static_cast<long long>(pathCordinates.size());
|
||||||
if (!editDistanceOnly) {
|
if (!editDistanceOnly) {
|
||||||
P p;
|
P p;
|
||||||
p.x = x;p.y = y;p.k = r;
|
p.x = x;
|
||||||
|
p.y = y;
|
||||||
|
p.k = r;
|
||||||
pathCordinates.push_back(p);
|
pathCordinates.push_back(p);
|
||||||
}
|
}
|
||||||
return y;
|
return y;
|
||||||
@ -632,10 +610,12 @@ namespace dtl {
|
|||||||
++py_idx;
|
++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
|
// all recording succeeded
|
||||||
} else {
|
} else {
|
||||||
// trivial difference
|
// trivial difference
|
||||||
@ -673,7 +653,8 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* record odd sequence in SES
|
* 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) {
|
while (idx < length) {
|
||||||
ses.addSequence(*it, idx, 0, et);
|
ses.addSequence(*it, idx, 0, et);
|
||||||
++it;
|
++it;
|
||||||
@ -698,11 +679,8 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* check if the sequences have been swapped
|
* check if the sequences have been swapped
|
||||||
*/
|
*/
|
||||||
bool inline wasSwapped () const {
|
bool inline wasSwapped() const { return swapped; }
|
||||||
return swapped;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
} // namespace dtl
|
||||||
|
|
||||||
#endif // DTL_DIFF_H
|
#endif // DTL_DIFF_H
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without
|
||||||
are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
@ -44,12 +44,11 @@ namespace dtl {
|
|||||||
* diff3 class template
|
* diff3 class template
|
||||||
* sequence must support random_access_iterator.
|
* sequence must support random_access_iterator.
|
||||||
*/
|
*/
|
||||||
template <typename elem, typename sequence = vector< elem >, typename comparator = Compare< elem > >
|
template <typename elem, typename sequence = vector<elem>,
|
||||||
class Diff3
|
typename comparator = Compare<elem>>
|
||||||
{
|
class Diff3 {
|
||||||
private:
|
private:
|
||||||
dtl_typedefs(elem, sequence)
|
dtl_typedefs(elem, sequence) sequence A;
|
||||||
sequence A;
|
|
||||||
sequence B;
|
sequence B;
|
||||||
sequence C;
|
sequence C;
|
||||||
sequence S;
|
sequence S;
|
||||||
@ -59,23 +58,17 @@ namespace dtl {
|
|||||||
elem csepabegin;
|
elem csepabegin;
|
||||||
elem csepa;
|
elem csepa;
|
||||||
elem csepaend;
|
elem csepaend;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Diff3() {}
|
Diff3() {}
|
||||||
Diff3 (const sequence& a,
|
Diff3(const sequence &a, const sequence &b, const sequence &c)
|
||||||
const sequence& b,
|
: A(a), B(b), C(c), diff_ba(b, a), diff_bc(b, c), conflict(false) {}
|
||||||
const sequence& c) : A(a), B(b), C(c),
|
|
||||||
diff_ba(b, a), diff_bc(b, c),
|
|
||||||
conflict(false) {}
|
|
||||||
|
|
||||||
~Diff3() {}
|
~Diff3() {}
|
||||||
|
|
||||||
bool isConflict () const {
|
bool isConflict() const { return conflict; }
|
||||||
return conflict;
|
|
||||||
}
|
|
||||||
|
|
||||||
sequence getMergedSequence () const {
|
sequence getMergedSequence() const { return S; }
|
||||||
return S;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* merge changes B and C into A
|
* 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 (!isEnd(ba_end, ba_it) || !isEnd(bc_end, bc_it)) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!isEnd(ba_end, ba_it) &&
|
if (!isEnd(ba_end, ba_it) && !isEnd(bc_end, bc_it) &&
|
||||||
!isEnd(bc_end, bc_it) &&
|
ba_it->first == bc_it->first && ba_it->second.type == SES_COMMON &&
|
||||||
ba_it->first == bc_it->first &&
|
|
||||||
ba_it->second.type == SES_COMMON &&
|
|
||||||
bc_it->second.type == SES_COMMON) {
|
bc_it->second.type == SES_COMMON) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isEnd(ba_end, ba_it)) seq.push_back(ba_it->first);
|
if (!isEnd(ba_end, ba_it))
|
||||||
else if (!isEnd(bc_end, bc_it)) seq.push_back(bc_it->first);
|
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(ba_end, ba_it);
|
||||||
forwardUntilEnd(bc_end, bc_it);
|
forwardUntilEnd(bc_end, bc_it);
|
||||||
}
|
}
|
||||||
if (isEnd(ba_end, ba_it) || isEnd(bc_end, bc_it)) break;
|
if (isEnd(ba_end, ba_it) || isEnd(bc_end, bc_it))
|
||||||
if ( ba_it->second.type == SES_COMMON
|
break;
|
||||||
&& bc_it->second.type == SES_DELETE) {
|
if (ba_it->second.type == SES_COMMON &&
|
||||||
|
bc_it->second.type == SES_DELETE) {
|
||||||
forwardUntilEnd(ba_end, ba_it);
|
forwardUntilEnd(ba_end, ba_it);
|
||||||
forwardUntilEnd(bc_end, bc_it);
|
forwardUntilEnd(bc_end, bc_it);
|
||||||
} else if (ba_it->second.type == SES_COMMON &&
|
} else if (ba_it->second.type == SES_COMMON &&
|
||||||
@ -226,20 +220,22 @@ namespace dtl {
|
|||||||
*/
|
*/
|
||||||
template <typename T_iter>
|
template <typename T_iter>
|
||||||
void inline forwardUntilEnd(const T_iter &end, T_iter &it) const {
|
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
|
* 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)) {
|
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;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
} // namespace dtl
|
||||||
|
|
||||||
#endif // DTL_DIFF3_H
|
#endif // DTL_DIFF3_H
|
||||||
|
10
dtl/Lcs.hpp
10
dtl/Lcs.hpp
@ -6,8 +6,8 @@
|
|||||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without
|
||||||
are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
@ -43,13 +43,11 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* Longest Common Subsequence template class
|
* Longest Common Subsequence template class
|
||||||
*/
|
*/
|
||||||
template <typename elem>
|
template <typename elem> class Lcs : public Sequence<elem> {
|
||||||
class Lcs : public Sequence< elem >
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Lcs() {}
|
Lcs() {}
|
||||||
~Lcs() {}
|
~Lcs() {}
|
||||||
};
|
};
|
||||||
}
|
} // namespace dtl
|
||||||
|
|
||||||
#endif // DTL_LCS_H
|
#endif // DTL_LCS_H
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without
|
||||||
are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
@ -43,23 +43,18 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* sequence class template
|
* sequence class template
|
||||||
*/
|
*/
|
||||||
template <typename elem>
|
template <typename elem> class Sequence {
|
||||||
class Sequence
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
typedef vector<elem> elemVec;
|
typedef vector<elem> elemVec;
|
||||||
Sequence() {}
|
Sequence() {}
|
||||||
virtual ~Sequence() {}
|
virtual ~Sequence() {}
|
||||||
|
|
||||||
elemVec getSequence () const {
|
elemVec getSequence() const { return sequence; }
|
||||||
return sequence;
|
void addSequence(elem e) { sequence.push_back(e); }
|
||||||
}
|
|
||||||
void addSequence (elem e) {
|
|
||||||
sequence.push_back(e);
|
|
||||||
}
|
|
||||||
protected:
|
protected:
|
||||||
elemVec sequence;
|
elemVec sequence;
|
||||||
};
|
};
|
||||||
}
|
} // namespace dtl
|
||||||
|
|
||||||
#endif // DTL_SEQUENCE_H
|
#endif // DTL_SEQUENCE_H
|
||||||
|
39
dtl/Ses.hpp
39
dtl/Ses.hpp
@ -6,8 +6,8 @@
|
|||||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without
|
||||||
are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
@ -43,44 +43,36 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* Shortest Edit Script template class
|
* Shortest Edit Script template class
|
||||||
*/
|
*/
|
||||||
template <typename elem>
|
template <typename elem> class Ses : public Sequence<elem> {
|
||||||
class Ses : public Sequence< elem >
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
typedef pair<elem, elemInfo> sesElem;
|
typedef pair<elem, elemInfo> sesElem;
|
||||||
typedef vector<sesElem> sesElemVec;
|
typedef vector<sesElem> sesElemVec;
|
||||||
public :
|
|
||||||
|
|
||||||
|
public:
|
||||||
Ses() : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(false) {
|
Ses() : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(false) {
|
||||||
nextDeleteIdx = 0;
|
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;
|
nextDeleteIdx = 0;
|
||||||
}
|
}
|
||||||
~Ses() {}
|
~Ses() {}
|
||||||
|
|
||||||
bool isOnlyAdd () const {
|
bool isOnlyAdd() const { return onlyAdd; }
|
||||||
return onlyAdd;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isOnlyDelete () const {
|
bool isOnlyDelete() const { return onlyDelete; }
|
||||||
return onlyDelete;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isOnlyCopy () const {
|
bool isOnlyCopy() const { return onlyCopy; }
|
||||||
return onlyCopy;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isOnlyOneOperation() const {
|
bool isOnlyOneOperation() const {
|
||||||
return isOnlyAdd() || isOnlyDelete() || isOnlyCopy();
|
return isOnlyAdd() || isOnlyDelete() || isOnlyCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isChange () const {
|
bool isChange() const { return !onlyCopy; }
|
||||||
return !onlyCopy;
|
|
||||||
}
|
|
||||||
|
|
||||||
using Sequence<elem>::addSequence;
|
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;
|
elemInfo info;
|
||||||
info.beforeIdx = beforeIdx;
|
info.beforeIdx = beforeIdx;
|
||||||
info.afterIdx = afterIdx;
|
info.afterIdx = afterIdx;
|
||||||
@ -116,9 +108,8 @@ namespace dtl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sesElemVec getSequence () const {
|
sesElemVec getSequence() const { return sequence; }
|
||||||
return sequence;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
sesElemVec sequence;
|
sesElemVec sequence;
|
||||||
bool onlyAdd;
|
bool onlyAdd;
|
||||||
@ -127,6 +118,6 @@ namespace dtl {
|
|||||||
bool deletesFirst;
|
bool deletesFirst;
|
||||||
size_t nextDeleteIdx;
|
size_t nextDeleteIdx;
|
||||||
};
|
};
|
||||||
}
|
} // namespace dtl
|
||||||
|
|
||||||
#endif // DTL_SES_H
|
#endif // DTL_SES_H
|
||||||
|
14
dtl/dtl.hpp
14
dtl/dtl.hpp
@ -6,8 +6,8 @@
|
|||||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without
|
||||||
are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
@ -36,12 +36,12 @@
|
|||||||
#ifndef DTL_H
|
#ifndef DTL_H
|
||||||
#define DTL_H
|
#define DTL_H
|
||||||
|
|
||||||
#include "variables.hpp"
|
|
||||||
#include "functors.hpp"
|
|
||||||
#include "Sequence.hpp"
|
|
||||||
#include "Lcs.hpp"
|
|
||||||
#include "Ses.hpp"
|
|
||||||
#include "Diff.hpp"
|
#include "Diff.hpp"
|
||||||
#include "Diff3.hpp"
|
#include "Diff3.hpp"
|
||||||
|
#include "Lcs.hpp"
|
||||||
|
#include "Sequence.hpp"
|
||||||
|
#include "Ses.hpp"
|
||||||
|
#include "functors.hpp"
|
||||||
|
#include "variables.hpp"
|
||||||
|
|
||||||
#endif // DTL_H
|
#endif // DTL_H
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without
|
||||||
are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
@ -43,14 +43,13 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* printer class template
|
* printer class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename stream = ostream >
|
template <typename sesElem, typename stream = ostream> class Printer {
|
||||||
class Printer
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Printer() : out_(cout) {}
|
Printer() : out_(cout) {}
|
||||||
Printer(stream &out) : out_(out) {}
|
Printer(stream &out) : out_(out) {}
|
||||||
virtual ~Printer() {}
|
virtual ~Printer() {}
|
||||||
virtual void operator()(const sesElem &se) const = 0;
|
virtual void operator()(const sesElem &se) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
stream &out_;
|
stream &out_;
|
||||||
};
|
};
|
||||||
@ -59,8 +58,7 @@ namespace dtl {
|
|||||||
* common element printer class template
|
* common element printer class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename stream = ostream>
|
template <typename sesElem, typename stream = ostream>
|
||||||
class CommonPrinter : public Printer < sesElem, stream >
|
class CommonPrinter : public Printer<sesElem, stream> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CommonPrinter() : Printer<sesElem, stream>() {}
|
CommonPrinter() : Printer<sesElem, stream>() {}
|
||||||
CommonPrinter(stream &out) : Printer<sesElem, stream>(out) {}
|
CommonPrinter(stream &out) : Printer<sesElem, stream>(out) {}
|
||||||
@ -74,8 +72,7 @@ namespace dtl {
|
|||||||
* ses element printer class template
|
* ses element printer class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename stream = ostream>
|
template <typename sesElem, typename stream = ostream>
|
||||||
class ChangePrinter : public Printer < sesElem, stream >
|
class ChangePrinter : public Printer<sesElem, stream> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
ChangePrinter() : Printer<sesElem, stream>() {}
|
ChangePrinter() : Printer<sesElem, stream>() {}
|
||||||
ChangePrinter(stream &out) : Printer<sesElem, stream>(out) {}
|
ChangePrinter(stream &out) : Printer<sesElem, stream>(out) {}
|
||||||
@ -98,23 +95,24 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* unified format element printer class template
|
* unified format element printer class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename stream = ostream >
|
template <typename sesElem, typename stream = ostream> class UniHunkPrinter {
|
||||||
class UniHunkPrinter
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
UniHunkPrinter() : out_(cout) {}
|
UniHunkPrinter() : out_(cout) {}
|
||||||
UniHunkPrinter(stream &out) : out_(out) {}
|
UniHunkPrinter(stream &out) : out_(out) {}
|
||||||
~UniHunkPrinter() {}
|
~UniHunkPrinter() {}
|
||||||
void operator()(const uniHunk<sesElem> &hunk) const {
|
void operator()(const uniHunk<sesElem> &hunk) const {
|
||||||
out_ << "@@"
|
out_ << "@@"
|
||||||
<< " -" << hunk.a << "," << hunk.b
|
<< " -" << hunk.a << "," << hunk.b << " +" << hunk.c << "," << hunk.d
|
||||||
<< " +" << hunk.c << "," << hunk.d
|
|
||||||
<< " @@" << endl;
|
<< " @@" << endl;
|
||||||
|
|
||||||
for_each(hunk.common[0].begin(), hunk.common[0].end(), CommonPrinter< sesElem, stream >(out_));
|
for_each(hunk.common[0].begin(), hunk.common[0].end(),
|
||||||
for_each(hunk.change.begin(), hunk.change.end(), ChangePrinter< sesElem, stream >(out_));
|
CommonPrinter<sesElem, stream>(out_));
|
||||||
for_each(hunk.common[1].begin(), hunk.common[1].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:
|
private:
|
||||||
stream &out_;
|
stream &out_;
|
||||||
};
|
};
|
||||||
@ -122,13 +120,12 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* storage class template
|
* storage class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename storedData >
|
template <typename sesElem, typename storedData> class Storage {
|
||||||
class Storage
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Storage(storedData &sd) : storedData_(sd) {}
|
Storage(storedData &sd) : storedData_(sd) {}
|
||||||
virtual ~Storage() {}
|
virtual ~Storage() {}
|
||||||
virtual void operator()(const sesElem &se) const = 0;
|
virtual void operator()(const sesElem &se) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
storedData &storedData_;
|
storedData &storedData_;
|
||||||
};
|
};
|
||||||
@ -136,9 +133,7 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* compare class template
|
* compare class template
|
||||||
*/
|
*/
|
||||||
template <typename elem>
|
template <typename elem> class Compare {
|
||||||
class Compare
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Compare() {}
|
Compare() {}
|
||||||
virtual ~Compare() {}
|
virtual ~Compare() {}
|
||||||
@ -146,6 +141,6 @@ namespace dtl {
|
|||||||
return e1 == e2;
|
return e1 == e2;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace dtl
|
||||||
|
|
||||||
#endif // DTL_FUNCTORS_H
|
#endif // DTL_FUNCTORS_H
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
Copyright (c) 2015 Tatsuhiko Kubo <cubicdaiya@gmail.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without
|
||||||
are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
@ -38,32 +38,32 @@
|
|||||||
#ifndef DTL_VARIABLES_H
|
#ifndef DTL_VARIABLES_H
|
||||||
#define DTL_VARIABLES_H
|
#define DTL_VARIABLES_H
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <list>
|
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace dtl {
|
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::cout;
|
||||||
|
using std::distance;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::rotate;
|
using std::fill;
|
||||||
using std::swap;
|
using std::for_each;
|
||||||
|
using std::list;
|
||||||
using std::max;
|
using std::max;
|
||||||
|
using std::ostream;
|
||||||
|
using std::pair;
|
||||||
|
using std::rotate;
|
||||||
|
using std::string;
|
||||||
|
using std::swap;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* version string
|
* version string
|
||||||
*/
|
*/
|
||||||
const string version = "1.20";
|
const string version = "1.21";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* type of edit for SES
|
* type of edit for SES
|
||||||
@ -88,7 +88,8 @@ namespace dtl {
|
|||||||
long long afterIdx; // index of after sequence
|
long long afterIdx; // index of after sequence
|
||||||
edit_t type; // type of edit(Add, Delete, Common)
|
edit_t type; // type of edit(Add, Delete, Common)
|
||||||
bool operator==(const eleminfo &other) const {
|
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;
|
} elemInfo;
|
||||||
|
|
||||||
@ -115,8 +116,7 @@ namespace dtl {
|
|||||||
/**
|
/**
|
||||||
* Structure of Unified Format Hunk
|
* Structure of Unified Format Hunk
|
||||||
*/
|
*/
|
||||||
template <typename sesElem>
|
template <typename sesElem> struct uniHunk {
|
||||||
struct uniHunk {
|
|
||||||
long long a, b, c, d; // @@ -a,b +c,d @@
|
long long a, b, c, d; // @@ -a,b +c,d @@
|
||||||
vector<sesElem> common[2]; // anteroposterior commons on changes
|
vector<sesElem> common[2]; // anteroposterior commons on changes
|
||||||
vector<sesElem> change; // changes
|
vector<sesElem> change; // changes
|
||||||
@ -136,7 +136,6 @@ namespace dtl {
|
|||||||
typedef typename sequence::const_iterator sequence_const_iter; \
|
typedef typename sequence::const_iterator sequence_const_iter; \
|
||||||
typedef typename elemVec::iterator elemVec_iter;
|
typedef typename elemVec::iterator elemVec_iter;
|
||||||
|
|
||||||
|
} // namespace dtl
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DTL_VARIABLES_H
|
#endif // DTL_VARIABLES_H
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <vector>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif // HAVE_UNISTD_H
|
#endif // HAVE_UNISTD_H
|
||||||
@ -21,8 +21,7 @@ typedef unsigned char elem;
|
|||||||
typedef vector<elem> sequence;
|
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)
|
static int create_byte_seq(const char *fs, sequence &seq) {
|
||||||
{
|
|
||||||
int fd;
|
int fd;
|
||||||
int siz;
|
int siz;
|
||||||
elem buf[BUFSIZ];
|
elem buf[BUFSIZ];
|
||||||
@ -44,8 +43,7 @@ static int create_byte_seq(const char *fs, sequence& seq)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) {
|
||||||
{
|
|
||||||
|
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
cerr << "Too few arguments." << endl;
|
||||||
|
@ -17,4 +17,3 @@ bool isFewArgs (int argc, int limit) {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#ifndef DTL_EXAMPLE_COMMON_H
|
#ifndef DTL_EXAMPLE_COMMON_H
|
||||||
#define DTL_EXAMPLE_COMMON_H
|
#define DTL_EXAMPLE_COMMON_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include <cassert>
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <dtl/dtl.hpp>
|
#include <dtl/dtl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include <cassert>
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include <dtl/dtl.hpp>
|
#include <dtl/dtl.hpp>
|
||||||
|
|
||||||
template <typename sesElem, typename stream = ostream>
|
template <typename sesElem, typename stream = ostream>
|
||||||
class customChangePrinter : public dtl::Printer < sesElem, stream >
|
class customChangePrinter : public dtl::Printer<sesElem, stream> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
customChangePrinter() : dtl::Printer<sesElem, stream>() {}
|
customChangePrinter() : dtl::Printer<sesElem, stream>() {}
|
||||||
customChangePrinter(stream &out) : dtl::Printer<sesElem, stream>(out) {}
|
customChangePrinter(stream &out) : dtl::Printer<sesElem, stream>(out) {}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <iostream>
|
#include <dtl/dtl.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dtl;
|
using namespace dtl;
|
||||||
@ -28,7 +28,8 @@ int main(int argc, char *argv[]){
|
|||||||
}
|
}
|
||||||
|
|
||||||
ifstream fs(s.c_str());
|
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);
|
dtl::Diff<elem, sequence>::printSES(ses);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include <dtl/dtl.hpp>
|
#include <dtl/dtl.hpp>
|
||||||
|
|
||||||
template <typename sesElem, typename storedData>
|
template <typename sesElem, typename storedData>
|
||||||
class CustomStorage : public dtl::Storage < sesElem, storedData >
|
class CustomStorage : public dtl::Storage<sesElem, storedData> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CustomStorage(storedData &sd) : dtl::Storage<sesElem, storedData>(sd) {}
|
CustomStorage(storedData &sd) : dtl::Storage<sesElem, storedData>(sd) {}
|
||||||
~CustomStorage() {}
|
~CustomStorage() {}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <iostream>
|
#include <dtl/dtl.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -18,8 +18,7 @@ using dtl::uniHunk;
|
|||||||
static void showStats(string fp1, string fp2);
|
static void showStats(string fp1, string fp2);
|
||||||
static void unifiedDiff(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;
|
const int MAX_LENGTH = 255;
|
||||||
char time_format[] = "%Y-%m-%d %H:%M:%S %z";
|
char time_format[] = "%Y-%m-%d %H:%M:%S %z";
|
||||||
time_t rawtime[2];
|
time_t rawtime[2];
|
||||||
@ -46,8 +45,7 @@ static void showStats (string fp1, string fp2)
|
|||||||
cout << "+++ " << fp2 << '\t' << buf[1] << endl;
|
cout << "+++ " << fp2 << '\t' << buf[1] << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unifiedDiff (string fp1, string fp2)
|
static void unifiedDiff(string fp1, string fp2) {
|
||||||
{
|
|
||||||
typedef string elem;
|
typedef string elem;
|
||||||
typedef vector<elem> sequence;
|
typedef vector<elem> sequence;
|
||||||
typedef pair<elem, elemInfo> sesElem;
|
typedef pair<elem, elemInfo> sesElem;
|
||||||
@ -80,9 +78,7 @@ static void unifiedDiff (string fp1, string fp2)
|
|||||||
diff.printUnifiedFormat();
|
diff.printUnifiedFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
if (isFewArgs(argc)) {
|
if (isFewArgs(argc)) {
|
||||||
cerr << "Too few arguments." << endl;
|
cerr << "Too few arguments." << endl;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
#include "dtl_test_common.hpp"
|
#include "dtl_test_common.hpp"
|
||||||
|
|
||||||
class Intdifftest : public ::testing::Test
|
class Intdifftest : public ::testing::Test {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
dtl_test_typedefs(int, vector< int >)
|
dtl_test_typedefs(int, vector<int>) typedef struct case_t {
|
||||||
typedef struct case_t {
|
|
||||||
sequence A;
|
sequence A;
|
||||||
sequence B;
|
sequence B;
|
||||||
size_t editdis;
|
size_t editdis;
|
||||||
@ -31,17 +29,19 @@ protected :
|
|||||||
string path_lses = create_path(test_name, diff_name, TYPE_DIFF_SES);
|
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_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_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_rses, diff,
|
||||||
create_file< elem, sequence, Compare< elem > >(path_rhunks, diff, TYPE_DIFF_UNI);
|
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_ses = cal_diff_uni(path_lses, path_rses);
|
||||||
c.editdis_uni = cal_diff_uni(path_lhunks, path_rhunks);
|
c.editdis_uni = cal_diff_uni(path_lhunks, path_rhunks);
|
||||||
c.path_rses = path_rses;
|
c.path_rses = path_rses;
|
||||||
c.path_rhunks = path_rhunks;
|
c.path_rhunks = path_rhunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
c.A = a;
|
c.A = a;
|
||||||
c.B = b;
|
c.B = b;
|
||||||
c.editdis = diff.getEditDistance();
|
c.editdis = diff.getEditDistance();
|
||||||
@ -74,10 +74,7 @@ protected :
|
|||||||
cases.push_back(createCase(A5, B5, "diff_test4"));
|
cases.push_back(createCase(A5, B5, "diff_test4"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown () {
|
void TearDown() { for_each(cases.begin(), cases.end(), Remover<case_t>()); }
|
||||||
for_each(cases.begin(), cases.end(), Remover< case_t >());
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
#include "dtl_test_common.hpp"
|
|
||||||
#include "comparators.hpp"
|
#include "comparators.hpp"
|
||||||
|
#include "dtl_test_common.hpp"
|
||||||
|
|
||||||
class Objdifftest : public ::testing::Test
|
class Objdifftest : public ::testing::Test {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
dtl_test_typedefs(string, vector<elem>)
|
dtl_test_typedefs(string, vector<elem>) typedef struct case_t {
|
||||||
typedef struct case_t {
|
|
||||||
sequence A;
|
sequence A;
|
||||||
sequence B;
|
sequence B;
|
||||||
sesElemVec expected;
|
sesElemVec expected;
|
||||||
@ -16,7 +14,8 @@ protected :
|
|||||||
caseVec obj_diff_cases;
|
caseVec obj_diff_cases;
|
||||||
|
|
||||||
template <typename comparator>
|
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;
|
case_t c;
|
||||||
elemVec lcs_v;
|
elemVec lcs_v;
|
||||||
string diff_name("objdiff");
|
string diff_name("objdiff");
|
||||||
@ -47,7 +46,8 @@ protected :
|
|||||||
ses.addSequence("brown", 3, 0, dtl::SES_DELETE);
|
ses.addSequence("brown", 3, 0, dtl::SES_DELETE);
|
||||||
ses.addSequence("Fox", 0, 3, dtl::SES_ADD);
|
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("f", 0, 4, dtl::SES_ADD);
|
||||||
ses.addSequence("h", 0, 5, 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"};
|
string array1[] = {"a", "d", "e", "f", "h"};
|
||||||
@ -86,16 +87,17 @@ protected :
|
|||||||
ses.addSequence("h", 5, 0, dtl::SES_DELETE);
|
ses.addSequence("h", 5, 0, dtl::SES_DELETE);
|
||||||
ses.addSequence("g", 0, 4, dtl::SES_ADD);
|
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() {
|
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
|
* Objdifftest
|
||||||
* check list:
|
* check list:
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
#include "dtl_test_common.hpp"
|
#include "dtl_test_common.hpp"
|
||||||
|
|
||||||
class Patchtest : public ::testing::Test
|
class Patchtest : public ::testing::Test {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
dtl_test_typedefs(char, string)
|
dtl_test_typedefs(char, string) typedef struct case_t {
|
||||||
typedef struct case_t {
|
|
||||||
sequence A;
|
sequence A;
|
||||||
sequence B;
|
sequence B;
|
||||||
Diff<elem, sequence> diff;
|
Diff<elem, sequence> diff;
|
||||||
@ -32,14 +30,69 @@ protected :
|
|||||||
cases.push_back(createCase("", "")); // 5
|
cases.push_back(createCase("", "")); // 5
|
||||||
cases.push_back(createCase("a", "")); // 6
|
cases.push_back(createCase("a", "")); // 6
|
||||||
cases.push_back(createCase("", "b")); // 7
|
cases.push_back(createCase("", "b")); // 7
|
||||||
cases.push_back(createCase("abcdefq3wefarhgorequgho4euhfteowauhfwehogfewrquhoi23hroewhoahfotrhguoiewahrgqqabcdef",
|
cases.push_back(createCase(
|
||||||
|
"abcdefq3wefarhgorequgho4euhfteowauhfwehogfewrquhoi23hroewhoahfotrhguoi"
|
||||||
|
"ewahrgqqabcdef",
|
||||||
"3abcdef4976fd86ouofita67t85r876e5e746578tgliuhopoqqabcdef")); // 8
|
"3abcdef4976fd86ouofita67t85r876e5e746578tgliuhopoqqabcdef")); // 8
|
||||||
cases.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/**
|
/**
|
||||||
|
@ -3,18 +3,20 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def path_chomp(path):
|
def path_chomp(path):
|
||||||
if path[-1] == '/':
|
if path[-1] == '/':
|
||||||
return path[:-1]
|
return path[:-1]
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
env = Environment(
|
env = Environment(
|
||||||
CPPFLAGS=['-Wall', '-O2'],
|
CPPFLAGS=['-Wall', '-O2'],
|
||||||
CPPPATH=['..'],
|
CPPPATH=['..'],
|
||||||
CXXFLAGS="-std=c++11",
|
CXXFLAGS="-std=c++11",
|
||||||
)
|
)
|
||||||
|
|
||||||
conf = Configure(env);
|
conf = Configure(env)
|
||||||
|
|
||||||
if not conf.CheckCXX():
|
if not conf.CheckCXX():
|
||||||
print("c++ compiler is not installed!")
|
print("c++ compiler is not installed!")
|
||||||
@ -33,10 +35,6 @@ test = env.Program(
|
|||||||
[Glob('*.cpp')],
|
[Glob('*.cpp')],
|
||||||
)
|
)
|
||||||
|
|
||||||
test_alias = env.Alias(
|
test_alias = env.Alias('check', test, test[0].abspath)
|
||||||
'check',
|
|
||||||
test,
|
|
||||||
test[0].abspath
|
|
||||||
)
|
|
||||||
|
|
||||||
env.AlwaysBuild(test_alias)
|
env.AlwaysBuild(test_alias)
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
#include "dtl_test_common.hpp"
|
|
||||||
#include "comparators.hpp"
|
#include "comparators.hpp"
|
||||||
|
#include "dtl_test_common.hpp"
|
||||||
|
|
||||||
class Strdiff3test : public ::testing::Test
|
class Strdiff3test : public ::testing::Test {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
dtl_test_typedefs(char, string)
|
dtl_test_typedefs(char, string) typedef struct case_t {
|
||||||
typedef struct case_t {
|
|
||||||
sequence S;
|
sequence S;
|
||||||
bool is_merge_success;
|
bool is_merge_success;
|
||||||
sequence merged_seq;
|
sequence merged_seq;
|
||||||
@ -31,41 +29,67 @@ protected :
|
|||||||
|
|
||||||
void SetUp() {
|
void SetUp() {
|
||||||
// merge test
|
// merge test
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("ab", "b", "bc", "abc")); // 0
|
merge_cases.push_back(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("bc", "b", "ab", "abc")); // 1
|
createCase<Compare<elem>>("ab", "b", "bc", "abc")); // 0
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("qqqabc", "abc", "abcdef", "qqqabcdef")); // 2
|
merge_cases.push_back(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("abcdef", "abc", "qqqabc", "qqqabcdef")); // 3
|
createCase<Compare<elem>>("bc", "b", "ab", "abc")); // 1
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aaacccbbb", "aaabbb", "aaabbbqqq", "aaacccbbbqqq")); // 4
|
merge_cases.push_back(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aaabbbqqq", "aaabbb", "aaacccbbb", "aaacccbbbqqq")); // 5
|
createCase<Compare<elem>>("qqqabc", "abc", "abcdef", "qqqabcdef")); // 2
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aeaacccbbb", "aaabbb", "aaabbbqqq", "aeaacccbbbqqq")); // 6
|
merge_cases.push_back(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aaabbbqqq", "aaabbb", "aeaacccbbb", "aeaacccbbbqqq")); // 7
|
createCase<Compare<elem>>("abcdef", "abc", "qqqabc", "qqqabcdef")); // 3
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aeaacccbbb", "aaabbb", "aaabebbqqq", "aeaacccbebbqqq")); // 8
|
merge_cases.push_back(createCase<Compare<elem>>(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aaabebbqqq", "aaabbb", "aeaacccbbb", "aeaacccbebbqqq")); // 9
|
"aaacccbbb", "aaabbb", "aaabbbqqq", "aaacccbbbqqq")); // 4
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aaacccbbb", "aaabbb", "aeaabbbqqq", "aeaacccbbbqqq")); // 10
|
merge_cases.push_back(createCase<Compare<elem>>(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aeaabbbqqq", "aaabbb", "aaacccbbb", "aeaacccbbbqqq")); // 11
|
"aaabbbqqq", "aaabbb", "aaacccbbb", "aaacccbbbqqq")); // 5
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aaacccbbb", "aaabbb", "aaabeebbeeqqq","aaacccbeebbeeqqq")); // 12
|
merge_cases.push_back(createCase<Compare<elem>>(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aaabeebbeeqqq", "aaabbb", "aaacccbbb", "aaacccbeebbeeqqq")); // 13
|
"aeaacccbbb", "aaabbb", "aaabbbqqq", "aeaacccbbbqqq")); // 6
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aiueo", "aeo", "aeKokaki", "aiueKokaki")); // 14
|
merge_cases.push_back(createCase<Compare<elem>>(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("aeKokaki", "aeo", "aiueo", "aiueKokaki")); // 15
|
"aaabbbqqq", "aaabbb", "aeaacccbbb", "aeaacccbbbqqq")); // 7
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("1234567390", "1234567890", "1239567890", "1239567390")); // 16
|
merge_cases.push_back(createCase<Compare<elem>>(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("1239567890", "1234567890", "1234567390", "1239567390")); // 17
|
"aeaacccbbb", "aaabbb", "aaabebbqqq", "aeaacccbebbqqq")); // 8
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("qabcdef", "abcdef", "ab", "qab")); // 18
|
merge_cases.push_back(createCase<Compare<elem>>(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("ab", "abcdef", "qabcdef", "qab")); // 19
|
"aaabebbqqq", "aaabbb", "aeaacccbbb", "aeaacccbebbqqq")); // 9
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("abcdf", "abcdef", "acdef", "acdf")); // 20
|
merge_cases.push_back(createCase<Compare<elem>>(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("acdef", "abcdef", "abcdf", "acdf")); // 21
|
"aaacccbbb", "aaabbb", "aeaabbbqqq", "aeaacccbbbqqq")); // 10
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("acdef", "abcdef", "abcdfaa", "acdfaa")); // 22
|
merge_cases.push_back(createCase<Compare<elem>>(
|
||||||
merge_cases.push_back(createCase< Compare < elem > >("abcdfaa", "abcdef", "acdef", "acdfaa")); // 23
|
"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 confliction test
|
||||||
detect_cases.push_back(createCase< Compare < elem > >("adc", "abc", "aec", "")); // 0
|
detect_cases.push_back(
|
||||||
detect_cases.push_back(createCase< Compare < elem > >("abqdcf", "abcdef", "abqqef", "")); // 1
|
createCase<Compare<elem>>("adc", "abc", "aec", "")); // 0
|
||||||
|
detect_cases.push_back(
|
||||||
|
createCase<Compare<elem>>("abqdcf", "abcdef", "abqqef", "")); // 1
|
||||||
|
|
||||||
// use custom comparator
|
// 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() {}
|
void TearDown() {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
#include "dtl_test_common.hpp"
|
|
||||||
#include "comparators.hpp"
|
#include "comparators.hpp"
|
||||||
|
#include "dtl_test_common.hpp"
|
||||||
|
|
||||||
class Strdifftest : public ::testing::Test
|
class Strdifftest : public ::testing::Test {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
dtl_test_typedefs(char, string)
|
dtl_test_typedefs(char, string) typedef struct case_t {
|
||||||
typedef struct case_t {
|
|
||||||
sequence A;
|
sequence A;
|
||||||
sequence B;
|
sequence B;
|
||||||
size_t editdis;
|
size_t editdis;
|
||||||
@ -25,7 +23,8 @@ protected :
|
|||||||
caseVec custom_cases;
|
caseVec custom_cases;
|
||||||
|
|
||||||
template <typename comparator>
|
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;
|
case_t c;
|
||||||
elemVec lcs_v;
|
elemVec lcs_v;
|
||||||
string diff_name("strdiff");
|
string diff_name("strdiff");
|
||||||
@ -43,7 +42,8 @@ protected :
|
|||||||
string path_lses = create_path(test_name, diff_name, TYPE_DIFF_SES);
|
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_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_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_lses);
|
||||||
diff_resultset_exist_check(path_lhunks);
|
diff_resultset_exist_check(path_lhunks);
|
||||||
|
|
||||||
@ -68,26 +68,38 @@ protected :
|
|||||||
|
|
||||||
void SetUp(void) {
|
void SetUp(void) {
|
||||||
diff_cases.push_back(createCase<Compare<elem>>("abc", "abd", "diff_test0"));
|
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(
|
||||||
diff_cases.push_back(createCase< Compare< elem > >("abcdef", "dacfea", "diff_test2"));
|
createCase<Compare<elem>>("acbdeacbed", "acebdabbabed", "diff_test1"));
|
||||||
diff_cases.push_back(createCase< Compare< elem > >("abcbda", "bdcaba", "diff_test3"));
|
diff_cases.push_back(
|
||||||
diff_cases.push_back(createCase< Compare< elem > >("bokko", "bokkko", "diff_test4"));
|
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>>("", "", "diff_test5"));
|
||||||
diff_cases.push_back(createCase<Compare<elem>>("a", "", "diff_test6"));
|
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>>("", "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(
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("acbdeacbed", "acebdabbabed", "", true));
|
createCase<Compare<elem>>("abc", "abd", "", true));
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("abcdef", "dacfea", "", true));
|
only_editdis_cases.push_back(
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("abcbda", "bdcaba", "", true));
|
createCase<Compare<elem>>("acbdeacbed", "acebdabbabed", "", true));
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("bokko", "bokkko", "", 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>>("", "", "", true));
|
||||||
only_editdis_cases.push_back(createCase<Compare<elem>>("a", "", "", 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>>("", "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() {
|
void TearDown() {
|
||||||
@ -96,7 +108,6 @@ protected :
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strdifftest
|
* Strdifftest
|
||||||
* check list is following
|
* check list is following
|
||||||
|
@ -14,8 +14,7 @@ public:
|
|||||||
if (a.length() == b.length()) {
|
if (a.length() == b.length()) {
|
||||||
bool equal = (strncasecmp(a.c_str(), b.c_str(), a.length()) == 0);
|
bool equal = (strncasecmp(a.c_str(), b.c_str(), a.length()) == 0);
|
||||||
return equal;
|
return equal;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
|
|
||||||
#include "dtl_test_common.hpp"
|
#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;
|
string ret;
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case TYPE_DIFF_SES:
|
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;
|
break;
|
||||||
case TYPE_DIFF_UNI:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
ret += is_use_suffix ? "_" : "";
|
ret += is_use_suffix ? "_" : "";
|
||||||
@ -47,9 +50,13 @@ bool is_file_exist (string& fs) {
|
|||||||
|
|
||||||
void diff_resultset_exist_check(string &fs) {
|
void diff_resultset_exist_check(string &fs) {
|
||||||
if (!is_file_exist(fs)) {
|
if (!is_file_exist(fs)) {
|
||||||
cerr << "======================================================Error!!!======================================================" << endl;
|
cerr << "======================================================Error!!!===="
|
||||||
|
"=================================================="
|
||||||
|
<< endl;
|
||||||
cerr << "diff result set:" << fs << " is not found." << endl;
|
cerr << "diff result set:" << fs << " is not found." << endl;
|
||||||
cerr << "======================================================Error!!!======================================================" << endl;
|
cerr << "======================================================Error!!!===="
|
||||||
|
"=================================================="
|
||||||
|
<< endl;
|
||||||
cerr << "excute dtl_test in dtl/test!" << endl;
|
cerr << "excute dtl_test in dtl/test!" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -2,30 +2,30 @@
|
|||||||
#ifndef DTL_TEST_COMMON
|
#ifndef DTL_TEST_COMMON
|
||||||
#define DTL_TEST_COMMON
|
#define DTL_TEST_COMMON
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <utility>
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <dtl/dtl.hpp>
|
#include <dtl/dtl.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
|
||||||
using std::vector;
|
|
||||||
using std::pair;
|
|
||||||
using std::ifstream;
|
using std::ifstream;
|
||||||
using std::ofstream;
|
using std::ofstream;
|
||||||
|
using std::pair;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
using dtl::Compare;
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
using dtl::Diff3;
|
using dtl::Diff3;
|
||||||
using dtl::Compare;
|
|
||||||
using dtl::SES_COMMON;
|
|
||||||
using dtl::SES_ADD;
|
|
||||||
using dtl::SES_DELETE;
|
|
||||||
using dtl::elemInfo;
|
using dtl::elemInfo;
|
||||||
|
using dtl::SES_ADD;
|
||||||
|
using dtl::SES_COMMON;
|
||||||
|
using dtl::SES_DELETE;
|
||||||
using dtl::uniHunk;
|
using dtl::uniHunk;
|
||||||
|
|
||||||
#define dtl_test_typedefs(e_type, seq_type) \
|
#define dtl_test_typedefs(e_type, seq_type) \
|
||||||
@ -38,13 +38,13 @@ using dtl::uniHunk;
|
|||||||
|
|
||||||
enum type_diff { TYPE_DIFF_SES, TYPE_DIFF_UNI };
|
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);
|
size_t cal_diff_uni(const string &path_l, const string &path_r);
|
||||||
bool is_file_exist(string &fs);
|
bool is_file_exist(string &fs);
|
||||||
void diff_resultset_exist_check(string &fs);
|
void diff_resultset_exist_check(string &fs);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> class Remover {
|
||||||
class Remover {
|
|
||||||
public:
|
public:
|
||||||
void operator()(const T &v) {
|
void operator()(const T &v) {
|
||||||
remove(v.path_rses.c_str());
|
remove(v.path_rses.c_str());
|
||||||
@ -53,7 +53,8 @@ public :
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename elem, typename sequence, typename comparator>
|
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;
|
ofstream ofs;
|
||||||
ofs.open(path.c_str());
|
ofs.open(path.c_str());
|
||||||
switch (t) {
|
switch (t) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user