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.
|
||||||
|
1272
dtl/Diff.hpp
1272
dtl/Diff.hpp
File diff suppressed because it is too large
Load Diff
376
dtl/Diff3.hpp
376
dtl/Diff3.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.
|
||||||
@ -40,206 +40,202 @@
|
|||||||
|
|
||||||
namespace dtl {
|
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;
|
Diff<elem, sequence, comparator> diff_ba;
|
||||||
Diff< elem, sequence, comparator > diff_ba;
|
Diff<elem, sequence, comparator> diff_bc;
|
||||||
Diff< elem, sequence, comparator > diff_bc;
|
bool conflict;
|
||||||
bool conflict;
|
elem csepabegin;
|
||||||
elem csepabegin;
|
elem csepa;
|
||||||
elem csepa;
|
elem csepaend;
|
||||||
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 () {}
|
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) {}
|
||||||
|
|
||||||
bool isConflict () const {
|
~Diff3() {}
|
||||||
return conflict;
|
|
||||||
|
bool isConflict() const { return conflict; }
|
||||||
|
|
||||||
|
sequence getMergedSequence() const { return S; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* merge changes B and C into A
|
||||||
|
*/
|
||||||
|
bool merge() {
|
||||||
|
if (diff_ba.getEditDistance() == 0) { // A == B
|
||||||
|
if (diff_bc.getEditDistance() == 0) { // A == B == C
|
||||||
|
S = B;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
S = C;
|
||||||
|
return true;
|
||||||
|
} else { // A != B
|
||||||
|
if (diff_bc.getEditDistance() == 0) { // A != B == C
|
||||||
|
S = A;
|
||||||
|
return true;
|
||||||
|
} else { // A != B != C
|
||||||
|
S = merge_();
|
||||||
|
if (isConflict()) { // conflict occured
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
sequence getMergedSequence () const {
|
/**
|
||||||
return S;
|
* compose differences
|
||||||
|
*/
|
||||||
|
void compose() {
|
||||||
|
diff_ba.compose();
|
||||||
|
diff_bc.compose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* merge implementation
|
||||||
|
*/
|
||||||
|
sequence merge_() {
|
||||||
|
elemVec seq;
|
||||||
|
Ses<elem> ses_ba = diff_ba.getSes();
|
||||||
|
Ses<elem> ses_bc = diff_bc.getSes();
|
||||||
|
sesElemVec ses_ba_v = ses_ba.getSequence();
|
||||||
|
sesElemVec ses_bc_v = ses_bc.getSequence();
|
||||||
|
sesElemVec_iter ba_it = ses_ba_v.begin();
|
||||||
|
sesElemVec_iter bc_it = ses_bc_v.begin();
|
||||||
|
sesElemVec_iter ba_end = ses_ba_v.end();
|
||||||
|
sesElemVec_iter bc_end = ses_bc_v.end();
|
||||||
|
|
||||||
|
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 &&
|
||||||
|
bc_it->second.type == SES_COMMON) {
|
||||||
|
// do nothing
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (!isEnd(ba_end, ba_it))
|
||||||
/**
|
seq.push_back(ba_it->first);
|
||||||
* merge changes B and C into A
|
else if (!isEnd(bc_end, bc_it))
|
||||||
*/
|
seq.push_back(bc_it->first);
|
||||||
bool merge () {
|
forwardUntilEnd(ba_end, ba_it);
|
||||||
if (diff_ba.getEditDistance() == 0) { // A == B
|
forwardUntilEnd(bc_end, bc_it);
|
||||||
if (diff_bc.getEditDistance() == 0) { // A == B == C
|
}
|
||||||
S = B;
|
if (isEnd(ba_end, ba_it) || isEnd(bc_end, bc_it))
|
||||||
return true;
|
break;
|
||||||
}
|
if (ba_it->second.type == SES_COMMON &&
|
||||||
S = C;
|
bc_it->second.type == SES_DELETE) {
|
||||||
return true;
|
forwardUntilEnd(ba_end, ba_it);
|
||||||
} else { // A != B
|
forwardUntilEnd(bc_end, bc_it);
|
||||||
if (diff_bc.getEditDistance() == 0) { // A != B == C
|
} else if (ba_it->second.type == SES_COMMON &&
|
||||||
S = A;
|
bc_it->second.type == SES_ADD) {
|
||||||
return true;
|
seq.push_back(bc_it->first);
|
||||||
} else { // A != B != C
|
forwardUntilEnd(bc_end, bc_it);
|
||||||
S = merge_();
|
} else if (ba_it->second.type == SES_DELETE &&
|
||||||
if (isConflict()) { // conflict occured
|
bc_it->second.type == SES_COMMON) {
|
||||||
return false;
|
forwardUntilEnd(ba_end, ba_it);
|
||||||
}
|
forwardUntilEnd(bc_end, bc_it);
|
||||||
}
|
} else if (ba_it->second.type == SES_DELETE &&
|
||||||
}
|
bc_it->second.type == SES_DELETE) {
|
||||||
return true;
|
if (ba_it->first == bc_it->first) {
|
||||||
|
forwardUntilEnd(ba_end, ba_it);
|
||||||
|
forwardUntilEnd(bc_end, bc_it);
|
||||||
|
} else {
|
||||||
|
// conflict
|
||||||
|
conflict = true;
|
||||||
|
return B;
|
||||||
}
|
}
|
||||||
|
} else if (ba_it->second.type == SES_DELETE &&
|
||||||
/**
|
bc_it->second.type == SES_ADD) {
|
||||||
* compose differences
|
// conflict
|
||||||
*/
|
conflict = true;
|
||||||
void compose () {
|
return B;
|
||||||
diff_ba.compose();
|
} else if (ba_it->second.type == SES_ADD &&
|
||||||
diff_bc.compose();
|
bc_it->second.type == SES_COMMON) {
|
||||||
|
seq.push_back(ba_it->first);
|
||||||
|
forwardUntilEnd(ba_end, ba_it);
|
||||||
|
} else if (ba_it->second.type == SES_ADD &&
|
||||||
|
bc_it->second.type == SES_DELETE) {
|
||||||
|
// conflict
|
||||||
|
conflict = true;
|
||||||
|
return B;
|
||||||
|
} else if (ba_it->second.type == SES_ADD &&
|
||||||
|
bc_it->second.type == SES_ADD) {
|
||||||
|
if (ba_it->first == bc_it->first) {
|
||||||
|
seq.push_back(ba_it->first);
|
||||||
|
forwardUntilEnd(ba_end, ba_it);
|
||||||
|
forwardUntilEnd(bc_end, bc_it);
|
||||||
|
} else {
|
||||||
|
// conflict
|
||||||
|
conflict = true;
|
||||||
|
return B;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private :
|
if (isEnd(ba_end, ba_it)) {
|
||||||
/**
|
addDecentSequence(bc_end, bc_it, seq);
|
||||||
* merge implementation
|
} else if (isEnd(bc_end, bc_it)) {
|
||||||
*/
|
addDecentSequence(ba_end, ba_it, seq);
|
||||||
sequence merge_ () {
|
}
|
||||||
elemVec seq;
|
|
||||||
Ses< elem > ses_ba = diff_ba.getSes();
|
|
||||||
Ses< elem > ses_bc = diff_bc.getSes();
|
|
||||||
sesElemVec ses_ba_v = ses_ba.getSequence();
|
|
||||||
sesElemVec ses_bc_v = ses_bc.getSequence();
|
|
||||||
sesElemVec_iter ba_it = ses_ba_v.begin();
|
|
||||||
sesElemVec_iter bc_it = ses_bc_v.begin();
|
|
||||||
sesElemVec_iter ba_end = ses_ba_v.end();
|
|
||||||
sesElemVec_iter bc_end = ses_bc_v.end();
|
|
||||||
|
|
||||||
while (!isEnd(ba_end, ba_it) || !isEnd(bc_end, bc_it)) {
|
sequence mergedSeq(seq.begin(), seq.end());
|
||||||
while (true) {
|
return mergedSeq;
|
||||||
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);
|
|
||||||
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) {
|
|
||||||
forwardUntilEnd(ba_end, ba_it);
|
|
||||||
forwardUntilEnd(bc_end, bc_it);
|
|
||||||
} else if (ba_it->second.type == SES_COMMON &&
|
|
||||||
bc_it->second.type == SES_ADD) {
|
|
||||||
seq.push_back(bc_it->first);
|
|
||||||
forwardUntilEnd(bc_end, bc_it);
|
|
||||||
} else if (ba_it->second.type == SES_DELETE &&
|
|
||||||
bc_it->second.type == SES_COMMON) {
|
|
||||||
forwardUntilEnd(ba_end, ba_it);
|
|
||||||
forwardUntilEnd(bc_end, bc_it);
|
|
||||||
} else if (ba_it->second.type == SES_DELETE &&
|
|
||||||
bc_it->second.type == SES_DELETE) {
|
|
||||||
if (ba_it->first == bc_it->first) {
|
|
||||||
forwardUntilEnd(ba_end, ba_it);
|
|
||||||
forwardUntilEnd(bc_end, bc_it);
|
|
||||||
} else {
|
|
||||||
// conflict
|
|
||||||
conflict = true;
|
|
||||||
return B;
|
|
||||||
}
|
|
||||||
} else if (ba_it->second.type == SES_DELETE &&
|
|
||||||
bc_it->second.type == SES_ADD) {
|
|
||||||
// conflict
|
|
||||||
conflict = true;
|
|
||||||
return B;
|
|
||||||
} else if (ba_it->second.type == SES_ADD &&
|
|
||||||
bc_it->second.type == SES_COMMON) {
|
|
||||||
seq.push_back(ba_it->first);
|
|
||||||
forwardUntilEnd(ba_end, ba_it);
|
|
||||||
} else if (ba_it->second.type == SES_ADD &&
|
|
||||||
bc_it->second.type == SES_DELETE) {
|
|
||||||
// conflict
|
|
||||||
conflict = true;
|
|
||||||
return B;
|
|
||||||
} else if (ba_it->second.type == SES_ADD &&
|
|
||||||
bc_it->second.type == SES_ADD) {
|
|
||||||
if (ba_it->first == bc_it->first) {
|
|
||||||
seq.push_back(ba_it->first);
|
|
||||||
forwardUntilEnd(ba_end, ba_it);
|
|
||||||
forwardUntilEnd(bc_end, bc_it);
|
|
||||||
} else {
|
|
||||||
// conflict
|
|
||||||
conflict = true;
|
|
||||||
return B;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isEnd(ba_end, ba_it)) {
|
/**
|
||||||
addDecentSequence(bc_end, bc_it, seq);
|
* join elem vectors
|
||||||
} else if (isEnd(bc_end, bc_it)) {
|
*/
|
||||||
addDecentSequence(ba_end, ba_it, seq);
|
void inline joinElemVec(elemVec &s1, elemVec &s2) const {
|
||||||
}
|
if (!s2.empty()) {
|
||||||
|
for (elemVec_iter vit = s2.begin(); vit != s2.end(); ++vit) {
|
||||||
|
s1.push_back(*vit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sequence mergedSeq(seq.begin(), seq.end());
|
/**
|
||||||
return mergedSeq;
|
* check if sequence is at end
|
||||||
}
|
*/
|
||||||
|
template <typename T_iter>
|
||||||
|
bool inline isEnd(const T_iter &end, const T_iter &it) const {
|
||||||
|
return it == end ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* join elem vectors
|
* increment iterator until iterator is at end
|
||||||
*/
|
*/
|
||||||
void inline joinElemVec (elemVec& s1, elemVec& s2) const {
|
template <typename T_iter>
|
||||||
if (!s2.empty()) {
|
void inline forwardUntilEnd(const T_iter &end, T_iter &it) const {
|
||||||
for (elemVec_iter vit=s2.begin();vit!=s2.end();++vit) {
|
if (!isEnd(end, it))
|
||||||
s1.push_back(*vit);
|
++it;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if sequence is at end
|
* add elements whose SES's type is ADD
|
||||||
*/
|
*/
|
||||||
template <typename T_iter>
|
void inline addDecentSequence(const sesElemVec_iter &end, sesElemVec_iter &it,
|
||||||
bool inline isEnd (const T_iter& end, const T_iter& it) const {
|
elemVec &seq) const {
|
||||||
return it == end ? true : false;
|
while (!isEnd(end, it)) {
|
||||||
}
|
if (it->second.type == SES_ADD)
|
||||||
|
seq.push_back(it->first);
|
||||||
/**
|
++it;
|
||||||
* increment iterator until iterator is at end
|
}
|
||||||
*/
|
}
|
||||||
template <typename T_iter>
|
};
|
||||||
void inline forwardUntilEnd (const T_iter& end, T_iter& it) const {
|
} // namespace dtl
|
||||||
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 {
|
|
||||||
while (!isEnd(end, it)) {
|
|
||||||
if (it->second.type == SES_ADD) seq.push_back(it->first);
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DTL_DIFF3_H
|
#endif // DTL_DIFF3_H
|
||||||
|
24
dtl/Lcs.hpp
24
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.
|
||||||
@ -40,16 +40,14 @@
|
|||||||
|
|
||||||
namespace dtl {
|
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:
|
||||||
{
|
Lcs() {}
|
||||||
public :
|
~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.
|
||||||
@ -40,26 +40,21 @@
|
|||||||
|
|
||||||
namespace dtl {
|
namespace dtl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sequence class template
|
* sequence class template
|
||||||
*/
|
*/
|
||||||
template <typename elem>
|
template <typename elem> class Sequence {
|
||||||
class Sequence
|
public:
|
||||||
{
|
typedef vector<elem> elemVec;
|
||||||
public :
|
Sequence() {}
|
||||||
typedef vector< elem > elemVec;
|
virtual ~Sequence() {}
|
||||||
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) {
|
protected:
|
||||||
sequence.push_back(e);
|
elemVec sequence;
|
||||||
}
|
};
|
||||||
protected :
|
} // namespace dtl
|
||||||
elemVec sequence;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DTL_SEQUENCE_H
|
#endif // DTL_SEQUENCE_H
|
||||||
|
155
dtl/Ses.hpp
155
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.
|
||||||
@ -40,93 +40,84 @@
|
|||||||
|
|
||||||
namespace dtl {
|
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:
|
||||||
{
|
typedef pair<elem, elemInfo> sesElem;
|
||||||
private :
|
typedef vector<sesElem> sesElemVec;
|
||||||
typedef pair< elem, elemInfo > sesElem;
|
|
||||||
typedef vector< sesElem > sesElemVec;
|
|
||||||
public :
|
|
||||||
|
|
||||||
Ses () : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(false) {
|
public:
|
||||||
nextDeleteIdx = 0;
|
Ses() : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(false) {
|
||||||
}
|
nextDeleteIdx = 0;
|
||||||
Ses (bool moveDel) : onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(moveDel) {
|
}
|
||||||
nextDeleteIdx = 0;
|
Ses(bool moveDel)
|
||||||
}
|
: onlyAdd(true), onlyDelete(true), onlyCopy(true), deletesFirst(moveDel) {
|
||||||
~Ses () {}
|
nextDeleteIdx = 0;
|
||||||
|
}
|
||||||
|
~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,
|
||||||
elemInfo info;
|
const edit_t type) {
|
||||||
info.beforeIdx = beforeIdx;
|
elemInfo info;
|
||||||
info.afterIdx = afterIdx;
|
info.beforeIdx = beforeIdx;
|
||||||
info.type = type;
|
info.afterIdx = afterIdx;
|
||||||
sesElem pe(e, info);
|
info.type = type;
|
||||||
if (!deletesFirst) {
|
sesElem pe(e, info);
|
||||||
sequence.push_back(pe);
|
if (!deletesFirst) {
|
||||||
}
|
sequence.push_back(pe);
|
||||||
switch (type) {
|
}
|
||||||
case SES_DELETE:
|
switch (type) {
|
||||||
onlyCopy = false;
|
case SES_DELETE:
|
||||||
onlyAdd = false;
|
onlyCopy = false;
|
||||||
if (deletesFirst) {
|
onlyAdd = false;
|
||||||
sequence.insert(sequence.begin() + nextDeleteIdx, pe);
|
if (deletesFirst) {
|
||||||
nextDeleteIdx++;
|
sequence.insert(sequence.begin() + nextDeleteIdx, pe);
|
||||||
}
|
nextDeleteIdx++;
|
||||||
break;
|
}
|
||||||
case SES_COMMON:
|
break;
|
||||||
onlyAdd = false;
|
case SES_COMMON:
|
||||||
onlyDelete = false;
|
onlyAdd = false;
|
||||||
if (deletesFirst) {
|
onlyDelete = false;
|
||||||
sequence.push_back(pe);
|
if (deletesFirst) {
|
||||||
nextDeleteIdx = sequence.size();
|
sequence.push_back(pe);
|
||||||
}
|
nextDeleteIdx = sequence.size();
|
||||||
break;
|
}
|
||||||
case SES_ADD:
|
break;
|
||||||
onlyDelete = false;
|
case SES_ADD:
|
||||||
onlyCopy = false;
|
onlyDelete = false;
|
||||||
if (deletesFirst) {
|
onlyCopy = false;
|
||||||
sequence.push_back(pe);
|
if (deletesFirst) {
|
||||||
}
|
sequence.push_back(pe);
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sesElemVec getSequence () const {
|
sesElemVec getSequence() const { return sequence; }
|
||||||
return sequence;
|
|
||||||
}
|
private:
|
||||||
private :
|
sesElemVec sequence;
|
||||||
sesElemVec sequence;
|
bool onlyAdd;
|
||||||
bool onlyAdd;
|
bool onlyDelete;
|
||||||
bool onlyDelete;
|
bool onlyCopy;
|
||||||
bool onlyCopy;
|
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
|
||||||
|
201
dtl/functors.hpp
201
dtl/functors.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.
|
||||||
@ -40,112 +40,107 @@
|
|||||||
|
|
||||||
namespace dtl {
|
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:
|
||||||
{
|
Printer() : out_(cout) {}
|
||||||
public :
|
Printer(stream &out) : out_(out) {}
|
||||||
Printer () : out_(cout) {}
|
virtual ~Printer() {}
|
||||||
Printer (stream& out) : out_(out) {}
|
virtual void operator()(const sesElem &se) const = 0;
|
||||||
virtual ~Printer () {}
|
|
||||||
virtual void operator() (const sesElem& se) const = 0;
|
|
||||||
protected :
|
|
||||||
stream& out_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
protected:
|
||||||
* common element printer class template
|
stream &out_;
|
||||||
*/
|
};
|
||||||
template <typename sesElem, typename stream = ostream >
|
|
||||||
class CommonPrinter : public Printer < sesElem, stream >
|
|
||||||
{
|
|
||||||
public :
|
|
||||||
CommonPrinter () : Printer < sesElem, stream > () {}
|
|
||||||
CommonPrinter (stream& out) : Printer < sesElem, stream > (out) {}
|
|
||||||
~CommonPrinter () {}
|
|
||||||
void operator() (const sesElem& se) const {
|
|
||||||
this->out_ << SES_MARK_COMMON << se.first << endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ses element printer class template
|
* common element printer class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename stream = ostream >
|
template <typename sesElem, typename stream = ostream>
|
||||||
class ChangePrinter : public Printer < sesElem, stream >
|
class CommonPrinter : public Printer<sesElem, stream> {
|
||||||
{
|
public:
|
||||||
public :
|
CommonPrinter() : Printer<sesElem, stream>() {}
|
||||||
ChangePrinter () : Printer < sesElem, stream > () {}
|
CommonPrinter(stream &out) : Printer<sesElem, stream>(out) {}
|
||||||
ChangePrinter (stream& out) : Printer < sesElem, stream > (out) {}
|
~CommonPrinter() {}
|
||||||
~ChangePrinter () {}
|
void operator()(const sesElem &se) const {
|
||||||
void operator() (const sesElem& se) const {
|
this->out_ << SES_MARK_COMMON << se.first << endl;
|
||||||
switch (se.second.type) {
|
}
|
||||||
case SES_ADD:
|
};
|
||||||
this->out_ << SES_MARK_ADD << se.first << endl;
|
|
||||||
break;
|
|
||||||
case SES_DELETE:
|
|
||||||
this->out_ << SES_MARK_DELETE << se.first << endl;
|
|
||||||
break;
|
|
||||||
case SES_COMMON:
|
|
||||||
this->out_ << SES_MARK_COMMON << se.first << endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unified format element printer class template
|
* ses element printer class template
|
||||||
*/
|
*/
|
||||||
template <typename sesElem, typename stream = ostream >
|
template <typename sesElem, typename stream = ostream>
|
||||||
class UniHunkPrinter
|
class ChangePrinter : public Printer<sesElem, stream> {
|
||||||
{
|
public:
|
||||||
public :
|
ChangePrinter() : Printer<sesElem, stream>() {}
|
||||||
UniHunkPrinter () : out_(cout) {}
|
ChangePrinter(stream &out) : Printer<sesElem, stream>(out) {}
|
||||||
UniHunkPrinter (stream& out) : out_(out) {}
|
~ChangePrinter() {}
|
||||||
~UniHunkPrinter () {}
|
void operator()(const sesElem &se) const {
|
||||||
void operator() (const uniHunk< sesElem >& hunk) const {
|
switch (se.second.type) {
|
||||||
out_ << "@@"
|
case SES_ADD:
|
||||||
<< " -" << hunk.a << "," << hunk.b
|
this->out_ << SES_MARK_ADD << se.first << endl;
|
||||||
<< " +" << hunk.c << "," << hunk.d
|
break;
|
||||||
<< " @@" << endl;
|
case SES_DELETE:
|
||||||
|
this->out_ << SES_MARK_DELETE << se.first << endl;
|
||||||
|
break;
|
||||||
|
case SES_COMMON:
|
||||||
|
this->out_ << SES_MARK_COMMON << se.first << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
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_));
|
* unified format element printer class template
|
||||||
for_each(hunk.common[1].begin(), hunk.common[1].end(), CommonPrinter< sesElem, stream >(out_));
|
*/
|
||||||
}
|
template <typename sesElem, typename stream = ostream> class UniHunkPrinter {
|
||||||
private :
|
public:
|
||||||
stream& out_;
|
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
|
||||||
|
<< " @@" << endl;
|
||||||
|
|
||||||
/**
|
for_each(hunk.common[0].begin(), hunk.common[0].end(),
|
||||||
* storage class template
|
CommonPrinter<sesElem, stream>(out_));
|
||||||
*/
|
for_each(hunk.change.begin(), hunk.change.end(),
|
||||||
template <typename sesElem, typename storedData >
|
ChangePrinter<sesElem, stream>(out_));
|
||||||
class Storage
|
for_each(hunk.common[1].begin(), hunk.common[1].end(),
|
||||||
{
|
CommonPrinter<sesElem, stream>(out_));
|
||||||
public:
|
}
|
||||||
Storage(storedData& sd) : storedData_(sd) {}
|
|
||||||
virtual ~Storage() {}
|
|
||||||
virtual void operator() (const sesElem& se) const = 0;
|
|
||||||
protected:
|
|
||||||
storedData& storedData_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
private:
|
||||||
* compare class template
|
stream &out_;
|
||||||
*/
|
};
|
||||||
template <typename elem>
|
|
||||||
class Compare
|
/**
|
||||||
{
|
* storage class template
|
||||||
public :
|
*/
|
||||||
Compare () {}
|
template <typename sesElem, typename storedData> class Storage {
|
||||||
virtual ~Compare () {}
|
public:
|
||||||
virtual inline bool impl (const elem& e1, const elem& e2) const {
|
Storage(storedData &sd) : storedData_(sd) {}
|
||||||
return e1 == e2;
|
virtual ~Storage() {}
|
||||||
}
|
virtual void operator()(const sesElem &se) const = 0;
|
||||||
};
|
|
||||||
}
|
protected:
|
||||||
|
storedData &storedData_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* compare class template
|
||||||
|
*/
|
||||||
|
template <typename elem> class Compare {
|
||||||
|
public:
|
||||||
|
Compare() {}
|
||||||
|
virtual ~Compare() {}
|
||||||
|
virtual inline bool impl(const elem &e1, const elem &e2) const {
|
||||||
|
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,105 +38,104 @@
|
|||||||
#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::cout;
|
||||||
using std::string;
|
using std::distance;
|
||||||
using std::pair;
|
using std::endl;
|
||||||
using std::ostream;
|
using std::fill;
|
||||||
using std::list;
|
using std::for_each;
|
||||||
using std::for_each;
|
using std::list;
|
||||||
using std::distance;
|
using std::max;
|
||||||
using std::fill;
|
using std::ostream;
|
||||||
using std::cout;
|
using std::pair;
|
||||||
using std::endl;
|
using std::rotate;
|
||||||
using std::rotate;
|
using std::string;
|
||||||
using std::swap;
|
using std::swap;
|
||||||
using std::max;
|
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
|
||||||
*/
|
*/
|
||||||
typedef int edit_t;
|
typedef int edit_t;
|
||||||
const edit_t SES_DELETE = -1;
|
const edit_t SES_DELETE = -1;
|
||||||
const edit_t SES_COMMON = 0;
|
const edit_t SES_COMMON = 0;
|
||||||
const edit_t SES_ADD = 1;
|
const edit_t SES_ADD = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mark of SES
|
* mark of SES
|
||||||
*/
|
*/
|
||||||
#define SES_MARK_DELETE "-"
|
#define SES_MARK_DELETE "-"
|
||||||
#define SES_MARK_COMMON " "
|
#define SES_MARK_COMMON " "
|
||||||
#define SES_MARK_ADD "+"
|
#define SES_MARK_ADD "+"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info for Unified Format
|
* info for Unified Format
|
||||||
*/
|
*/
|
||||||
typedef struct eleminfo {
|
typedef struct eleminfo {
|
||||||
long long beforeIdx; // index of prev sequence
|
long long beforeIdx; // index of prev sequence
|
||||||
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;
|
||||||
|
|
||||||
const long long DTL_SEPARATE_SIZE = 3;
|
const long long DTL_SEPARATE_SIZE = 3;
|
||||||
const long long DTL_CONTEXT_SIZE = 3;
|
const long long DTL_CONTEXT_SIZE = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cordinate for registering route
|
* cordinate for registering route
|
||||||
*/
|
*/
|
||||||
typedef struct Point {
|
typedef struct Point {
|
||||||
long long x; // x cordinate
|
long long x; // x cordinate
|
||||||
long long y; // y cordinate
|
long long y; // y cordinate
|
||||||
long long k; // vertex
|
long long k; // vertex
|
||||||
} P;
|
} P;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* limit of cordinate size
|
* limit of cordinate size
|
||||||
*/
|
*/
|
||||||
const unsigned long long MAX_CORDINATES_SIZE = 2000000;
|
const unsigned long long MAX_CORDINATES_SIZE = 2000000;
|
||||||
|
|
||||||
typedef vector< long long > editPath;
|
typedef vector<long long> editPath;
|
||||||
typedef vector< P > editPathCordinates;
|
typedef vector<P> editPathCordinates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
long long inc_dec_count; // count of increace and decrease
|
||||||
long long inc_dec_count; // count of increace and decrease
|
};
|
||||||
};
|
|
||||||
|
|
||||||
#define dtl_typedefs(elem, sequence) \
|
#define dtl_typedefs(elem, sequence) \
|
||||||
typedef pair< elem, elemInfo > sesElem; \
|
typedef pair<elem, elemInfo> sesElem; \
|
||||||
typedef vector< sesElem > sesElemVec; \
|
typedef vector<sesElem> sesElemVec; \
|
||||||
typedef vector< uniHunk< sesElem > > uniHunkVec; \
|
typedef vector<uniHunk<sesElem>> uniHunkVec; \
|
||||||
typedef list< elem > elemList; \
|
typedef list<elem> elemList; \
|
||||||
typedef vector< elem > elemVec; \
|
typedef vector<elem> elemVec; \
|
||||||
typedef typename uniHunkVec::iterator uniHunkVec_iter; \
|
typedef typename uniHunkVec::iterator uniHunkVec_iter; \
|
||||||
typedef typename sesElemVec::iterator sesElemVec_iter; \
|
typedef typename sesElemVec::iterator sesElemVec_iter; \
|
||||||
typedef typename elemList::iterator elemList_iter; \
|
typedef typename elemList::iterator elemList_iter; \
|
||||||
typedef typename sequence::iterator sequence_iter; \
|
typedef typename sequence::iterator sequence_iter; \
|
||||||
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
|
||||||
@ -17,57 +17,55 @@ using namespace std;
|
|||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
typedef unsigned char elem;
|
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];
|
if ((fd = open(fs, O_RDONLY)) == -1) {
|
||||||
if ((fd = open(fs, O_RDONLY)) == -1) {
|
cout << "Opening failed." << endl;
|
||||||
cout << "Opening failed." << endl;
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
while ((siz = read(fd, buf, sizeof(buf))) > 0) {
|
||||||
while ((siz = read(fd, buf, sizeof(buf))) > 0) {
|
for (int i = 0; i < siz; ++i) {
|
||||||
for (int i=0;i<siz;++i) {
|
seq.push_back(buf[i]);
|
||||||
seq.push_back(buf[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (siz < 0) {
|
|
||||||
close(fd);
|
|
||||||
cout << "Read error." << endl;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (siz < 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
cout << "Read error." << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
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;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
string fs1(argv[1]);
|
string fs1(argv[1]);
|
||||||
string fs2(argv[2]);
|
string fs2(argv[2]);
|
||||||
sequence seq1;
|
sequence seq1;
|
||||||
sequence seq2;
|
sequence seq2;
|
||||||
|
|
||||||
create_byte_seq(fs1.c_str(), seq1);
|
create_byte_seq(fs1.c_str(), seq1);
|
||||||
create_byte_seq(fs2.c_str(), seq2);
|
create_byte_seq(fs2.c_str(), seq2);
|
||||||
|
|
||||||
Diff< elem, sequence > d(seq1, seq2);
|
Diff<elem, sequence> d(seq1, seq2);
|
||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
if (d.getEditDistance() == 0) {
|
if (d.getEditDistance() == 0) {
|
||||||
cout << fs1 << " is the same as " << fs2 << endl;
|
cout << fs1 << " is the same as " << fs2 << endl;
|
||||||
} else {
|
} else {
|
||||||
cout << fs1 << " is different from " << fs2 << endl;
|
cout << fs1 << " is different from " << fs2 << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
bool isFileExist (string& fs) {
|
bool isFileExist(string &fs) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if ((fp = fopen(fs.c_str(), "r")) == NULL) {
|
if ((fp = fopen(fs.c_str(), "r")) == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFewArgs (int argc, int limit) {
|
bool isFewArgs(int argc, int limit) {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (argc < limit) {
|
if (argc < limit) {
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
#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;
|
||||||
|
|
||||||
bool isFileExist (string& fs);
|
bool isFileExist(string &fs);
|
||||||
bool isFewArgs (int argc, int limit = 3);
|
bool isFewArgs(int argc, int limit = 3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,73 +1,73 @@
|
|||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
string A(argv[1]);
|
string A(argv[1]);
|
||||||
string B(argv[2]);
|
string B(argv[2]);
|
||||||
bool fileExist = true;
|
bool fileExist = true;
|
||||||
|
|
||||||
if (!isFileExist(A)) {
|
if (!isFileExist(A)) {
|
||||||
cerr << "file A does not exist" << endl;
|
cerr << "file A does not exist" << endl;
|
||||||
fileExist = false;
|
fileExist = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFileExist(B)) {
|
if (!isFileExist(B)) {
|
||||||
cerr << "file B does not exist" << endl;
|
cerr << "file B does not exist" << endl;
|
||||||
fileExist = false;
|
fileExist = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fileExist) {
|
if (!fileExist) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef string elem;
|
typedef string elem;
|
||||||
typedef vector< elem > sequence;
|
typedef vector<elem> sequence;
|
||||||
|
|
||||||
ifstream Aifs(A.c_str());
|
ifstream Aifs(A.c_str());
|
||||||
ifstream Bifs(B.c_str());
|
ifstream Bifs(B.c_str());
|
||||||
elem buf;
|
elem buf;
|
||||||
sequence ALines, BLines;
|
sequence ALines, BLines;
|
||||||
ostringstream ossLine, ossInfo;
|
ostringstream ossLine, ossInfo;
|
||||||
|
|
||||||
while(getline(Aifs, buf)){
|
while (getline(Aifs, buf)) {
|
||||||
ALines.push_back(buf);
|
ALines.push_back(buf);
|
||||||
}
|
}
|
||||||
while(getline(Bifs, buf)){
|
while (getline(Bifs, buf)) {
|
||||||
BLines.push_back(buf);
|
BLines.push_back(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
Diff< elem > d(ALines, BLines);
|
Diff<elem> d(ALines, BLines);
|
||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
sequence s1 = ALines;
|
sequence s1 = ALines;
|
||||||
sequence s2 = d.patch(s1);
|
sequence s2 = d.patch(s1);
|
||||||
|
|
||||||
// fpatch
|
// fpatch
|
||||||
assert(BLines == s2);
|
assert(BLines == s2);
|
||||||
cout << "fpatch succeeded" << endl;
|
cout << "fpatch succeeded" << endl;
|
||||||
|
|
||||||
d.composeUnifiedHunks();
|
d.composeUnifiedHunks();
|
||||||
sequence s3 = d.uniPatch(s1);
|
sequence s3 = d.uniPatch(s1);
|
||||||
|
|
||||||
// unipatch
|
// unipatch
|
||||||
assert(BLines == s3);
|
assert(BLines == s3);
|
||||||
cout << "unipatch succeeded" << endl;
|
cout << "unipatch succeeded" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,49 +1,49 @@
|
|||||||
|
|
||||||
|
#include <dtl/dtl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <dtl/dtl.hpp>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
int main(int, char**){
|
int main(int, char **) {
|
||||||
|
|
||||||
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
int b[] = {3, 5, 1, 4, 5, 1, 7, 9, 6, 10};
|
int b[] = {3, 5, 1, 4, 5, 1, 7, 9, 6, 10};
|
||||||
int asiz = sizeof(a) / sizeof(int);
|
int asiz = sizeof(a) / sizeof(int);
|
||||||
int bsiz = sizeof(b) / sizeof(int);
|
int bsiz = sizeof(b) / sizeof(int);
|
||||||
for (int i=0;i<asiz;++i) {
|
for (int i = 0; i < asiz; ++i) {
|
||||||
cout << a[i] << " ";
|
cout << a[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
for (int i=0;i<bsiz;++i) {
|
for (int i = 0; i < bsiz; ++i) {
|
||||||
cout << b[i] << " ";
|
cout << b[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
typedef int elem;
|
typedef int elem;
|
||||||
typedef vector< int > sequence;
|
typedef vector<int> sequence;
|
||||||
|
|
||||||
sequence A(&a[0], &a[asiz]);
|
sequence A(&a[0], &a[asiz]);
|
||||||
sequence B(&b[0], &b[bsiz]);
|
sequence B(&b[0], &b[bsiz]);
|
||||||
Diff< elem > d(A, B);
|
Diff<elem> d(A, B);
|
||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
// editDistance
|
// editDistance
|
||||||
cout << "editDistance:" << d.getEditDistance() << endl;
|
cout << "editDistance:" << d.getEditDistance() << endl;
|
||||||
|
|
||||||
// Longest Common Subsequence
|
// Longest Common Subsequence
|
||||||
sequence lcs_v = d.getLcsVec();
|
sequence lcs_v = d.getLcsVec();
|
||||||
cout << "LCS: ";
|
cout << "LCS: ";
|
||||||
for (sequence::iterator vit=lcs_v.begin();vit!=lcs_v.end();++vit) {
|
for (sequence::iterator vit = lcs_v.begin(); vit != lcs_v.end(); ++vit) {
|
||||||
cout << *vit << " ";
|
cout << *vit << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
// Shortest Edit Script
|
// Shortest Edit Script
|
||||||
cout << "SES" << endl;
|
cout << "SES" << endl;
|
||||||
d.printSES();
|
d.printSES();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,57 +1,57 @@
|
|||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
using dtl::Diff3;
|
using dtl::Diff3;
|
||||||
|
|
||||||
int main(int, char**) {
|
int main(int, char **) {
|
||||||
|
|
||||||
int a[10] = {1, 2, 3, 4, 5, 6, 7, 3, 9, 10};
|
int a[10] = {1, 2, 3, 4, 5, 6, 7, 3, 9, 10};
|
||||||
int b[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
int b[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
int c[10] = {1, 2, 3, 9, 5, 6, 7, 8, 9, 10};
|
int c[10] = {1, 2, 3, 9, 5, 6, 7, 8, 9, 10};
|
||||||
int answer[10] = {1, 2, 3, 9, 5, 6, 7, 3, 9, 10};
|
int answer[10] = {1, 2, 3, 9, 5, 6, 7, 3, 9, 10};
|
||||||
|
|
||||||
cout << "a:";
|
cout << "a:";
|
||||||
for (int i=0;i<10;++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
cout << a[i] << " ";
|
cout << a[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
cout << "b:";
|
cout << "b:";
|
||||||
for (int i=0;i<10;++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
cout << b[i] << " ";
|
cout << b[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
cout << "c:";
|
cout << "c:";
|
||||||
for (int i=0;i<10;++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
cout << c[i] << " ";
|
cout << c[i] << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
typedef int elem;
|
typedef int elem;
|
||||||
typedef vector< int > sequence;
|
typedef vector<int> sequence;
|
||||||
sequence A(&a[0], &a[10]);
|
sequence A(&a[0], &a[10]);
|
||||||
sequence B(&b[0], &b[10]);
|
sequence B(&b[0], &b[10]);
|
||||||
sequence C(&c[0], &c[10]);
|
sequence C(&c[0], &c[10]);
|
||||||
sequence Answer(&answer[0], &answer[10]);
|
sequence Answer(&answer[0], &answer[10]);
|
||||||
Diff3< elem > diff3(A, B, C);
|
Diff3<elem> diff3(A, B, C);
|
||||||
diff3.compose();
|
diff3.compose();
|
||||||
if (!diff3.merge()) {
|
if (!diff3.merge()) {
|
||||||
cerr << "conflict." << endl;
|
cerr << "conflict." << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sequence s = diff3.getMergedSequence();
|
sequence s = diff3.getMergedSequence();
|
||||||
cout << "s:";
|
cout << "s:";
|
||||||
for (sequence::iterator it=s.begin();it!=s.end();++it) {
|
for (sequence::iterator it = s.begin(); it != s.end(); ++it) {
|
||||||
cout << *it << " ";
|
cout << *it << " ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
assert(s == Answer);
|
assert(s == Answer);
|
||||||
cout << "intdiff3 OK" << endl;
|
cout << "intdiff3 OK" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -11,34 +11,34 @@ using dtl::Diff;
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
|
|
||||||
Diff< elem, sequence > d(A, B);
|
Diff<elem, sequence> d(A, B);
|
||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
sequence s1(A);
|
sequence s1(A);
|
||||||
sequence s2 = d.patch(s1);
|
sequence s2 = d.patch(s1);
|
||||||
d.composeUnifiedHunks();
|
d.composeUnifiedHunks();
|
||||||
sequence s3 = d.uniPatch(s1);
|
sequence s3 = d.uniPatch(s1);
|
||||||
|
|
||||||
cout << "before:" << s1 << endl;
|
cout << "before:" << s1 << endl;
|
||||||
cout << "after :" << s2 << endl;
|
cout << "after :" << s2 << endl;
|
||||||
assert(B == s2);
|
assert(B == s2);
|
||||||
cout << "patch succeeded" << endl;
|
cout << "patch succeeded" << endl;
|
||||||
|
|
||||||
cout << "before:" << s1 << endl;
|
cout << "before:" << s1 << endl;
|
||||||
cout << "after :" << s3 << endl;
|
cout << "after :" << s3 << endl;
|
||||||
assert(B == s3);
|
assert(B == s3);
|
||||||
cout << "unipatch succeeded" << endl;
|
cout << "unipatch succeeded" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3,26 +3,25 @@
|
|||||||
|
|
||||||
#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) {}
|
~customChangePrinter() {}
|
||||||
~customChangePrinter () {}
|
void operator()(const sesElem &se) const {
|
||||||
void operator() (const sesElem& se) const {
|
switch (se.second.type) {
|
||||||
switch (se.second.type) {
|
case dtl::SES_ADD:
|
||||||
case dtl::SES_ADD:
|
this->out_ << "Add: " << se.first << std::endl;
|
||||||
this->out_ << "Add: " << se.first << std::endl;
|
break;
|
||||||
break;
|
case dtl::SES_DELETE:
|
||||||
case dtl::SES_DELETE:
|
this->out_ << "Delete: " << se.first << std::endl;
|
||||||
this->out_ << "Delete: " << se.first << std::endl;
|
break;
|
||||||
break;
|
case dtl::SES_COMMON:
|
||||||
case dtl::SES_COMMON:
|
this->out_ << "Common: " << se.first << std::endl;
|
||||||
this->out_ << "Common: " << se.first << std::endl;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DTL_PRINTERS
|
#endif // DTL_PRINTERS
|
||||||
|
@ -1,35 +1,36 @@
|
|||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc, 2)) {
|
if (isFewArgs(argc, 2)) {
|
||||||
cerr << "Too few arguments." << endl;
|
cerr << "Too few arguments." << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef string elem;
|
typedef string elem;
|
||||||
typedef vector< string > sequence;
|
typedef vector<string> sequence;
|
||||||
|
|
||||||
string s(argv[1]);
|
string s(argv[1]);
|
||||||
|
|
||||||
if (!isFileExist(s)) {
|
if (!isFileExist(s)) {
|
||||||
cerr << s << " is invalid." << endl;
|
cerr << s << " is invalid." << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifstream fs(s.c_str());
|
ifstream fs(s.c_str());
|
||||||
const Ses< elem > ses = Diff< elem, sequence >::composeSesFromStream< ifstream >(fs);
|
const Ses<elem> ses =
|
||||||
dtl::Diff< elem, sequence >::printSES(ses);
|
Diff<elem, sequence>::composeSesFromStream<ifstream>(fs);
|
||||||
|
dtl::Diff<elem, sequence>::printSES(ses);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3,25 +3,24 @@
|
|||||||
|
|
||||||
#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() {}
|
void operator()(const sesElem &se) const {
|
||||||
void operator() (const sesElem& se) const {
|
switch (se.second.type) {
|
||||||
switch (se.second.type) {
|
case dtl::SES_ADD:
|
||||||
case dtl::SES_ADD:
|
this->storedData_ = this->storedData_ + "Add: " + se.first + "\n";
|
||||||
this->storedData_ = this->storedData_ + "Add: " + se.first + "\n";
|
break;
|
||||||
break;
|
case dtl::SES_DELETE:
|
||||||
case dtl::SES_DELETE:
|
this->storedData_ = this->storedData_ + "Delete: " + se.first + "\n";
|
||||||
this->storedData_ = this->storedData_ + "Delete: " + se.first + "\n";
|
break;
|
||||||
break;
|
case dtl::SES_COMMON:
|
||||||
case dtl::SES_COMMON:
|
this->storedData_ = this->storedData_ + "Common: " + se.first + "\n";
|
||||||
this->storedData_ = this->storedData_ + "Common: " + se.first + "\n";
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DTL_STORAGE
|
#endif // DTL_STORAGE
|
||||||
|
@ -1,42 +1,42 @@
|
|||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
|
|
||||||
Diff< elem, sequence > d(A, B);
|
Diff<elem, sequence> d(A, B);
|
||||||
//d.onOnlyEditDistance();
|
// d.onOnlyEditDistance();
|
||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
// editDistance
|
// editDistance
|
||||||
cout << "editDistance:" << d.getEditDistance() << endl;
|
cout << "editDistance:" << d.getEditDistance() << endl;
|
||||||
|
|
||||||
// Longest Common Subsequence
|
// Longest Common Subsequence
|
||||||
vector< elem > lcs_v = d.getLcsVec();
|
vector<elem> lcs_v = d.getLcsVec();
|
||||||
sequence lcs_s(lcs_v.begin(), lcs_v.end());
|
sequence lcs_s(lcs_v.begin(), lcs_v.end());
|
||||||
cout << "LCS:" << lcs_s << endl;
|
cout << "LCS:" << lcs_s << endl;
|
||||||
|
|
||||||
// Shortest Edit Script
|
// Shortest Edit Script
|
||||||
cout << "SES" << endl;
|
cout << "SES" << endl;
|
||||||
d.printSES();
|
d.printSES();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
using dtl::Diff3;
|
using dtl::Diff3;
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (isFewArgs(argc, 4)) {
|
if (isFewArgs(argc, 4)) {
|
||||||
cerr << "Too few arguments." << endl;
|
cerr << "Too few arguments." << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
sequence C(argv[3]);
|
sequence C(argv[3]);
|
||||||
|
|
||||||
Diff3< elem, sequence > diff3(A, B, C);
|
|
||||||
diff3.compose();
|
|
||||||
if (!diff3.merge()) {
|
|
||||||
cerr << "conflict." << endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
cout << "result:" << diff3.getMergedSequence() << endl;
|
|
||||||
|
|
||||||
|
Diff3<elem, sequence> diff3(A, B, C);
|
||||||
|
diff3.compose();
|
||||||
|
if (!diff3.merge()) {
|
||||||
|
cerr << "conflict." << endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
cout << "result:" << diff3.getMergedSequence() << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
@ -10,26 +10,26 @@ using namespace std;
|
|||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
|
|
||||||
Diff< elem, sequence > d(A, B);
|
Diff<elem, sequence> d(A, B);
|
||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
// Shortest Edit Script
|
// Shortest Edit Script
|
||||||
cout << "SES" << endl;
|
cout << "SES" << endl;
|
||||||
|
|
||||||
d.printSES < ostream, customChangePrinter > (cout);
|
d.printSES<ostream, customChangePrinter>(cout);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
|
|
||||||
@ -9,30 +9,30 @@ using namespace std;
|
|||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
|
|
||||||
Diff< elem, sequence > d(A, B);
|
Diff<elem, sequence> d(A, B);
|
||||||
d.compose();
|
d.compose();
|
||||||
|
|
||||||
// Shortest Edit Script
|
// Shortest Edit Script
|
||||||
cout << "SES" << endl;
|
cout << "SES" << endl;
|
||||||
|
|
||||||
string result;
|
string result;
|
||||||
|
|
||||||
d.storeSES < string, CustomStorage > (result);
|
d.storeSES<string, CustomStorage>(result);
|
||||||
|
|
||||||
cout << result;
|
cout << result;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -15,97 +15,93 @@ using dtl::Diff;
|
|||||||
using dtl::elemInfo;
|
using dtl::elemInfo;
|
||||||
using dtl::uniHunk;
|
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];
|
struct tm *timeinfo[2];
|
||||||
struct tm *timeinfo[2];
|
struct stat st[2];
|
||||||
struct stat st[2];
|
|
||||||
|
|
||||||
if (stat(fp1.c_str(), &st[0]) == -1) {
|
if (stat(fp1.c_str(), &st[0]) == -1) {
|
||||||
cerr << "argv1 is invalid." << endl;
|
cerr << "argv1 is invalid." << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (stat(fp2.c_str(), &st[1]) == -1) {
|
if (stat(fp2.c_str(), &st[1]) == -1) {
|
||||||
cerr << "argv2 is invalid" << endl;
|
cerr << "argv2 is invalid" << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[2][MAX_LENGTH + 1];
|
char buf[2][MAX_LENGTH + 1];
|
||||||
rawtime[0] = st[0].st_mtime;
|
rawtime[0] = st[0].st_mtime;
|
||||||
timeinfo[0] = localtime(&rawtime[0]);
|
timeinfo[0] = localtime(&rawtime[0]);
|
||||||
strftime(buf[0], MAX_LENGTH, time_format, timeinfo[0]);
|
strftime(buf[0], MAX_LENGTH, time_format, timeinfo[0]);
|
||||||
cout << "--- " << fp1 << '\t' << buf[0] << endl;
|
cout << "--- " << fp1 << '\t' << buf[0] << endl;
|
||||||
rawtime[1] = st[1].st_mtime;
|
rawtime[1] = st[1].st_mtime;
|
||||||
timeinfo[1] = localtime(&rawtime[1]);
|
timeinfo[1] = localtime(&rawtime[1]);
|
||||||
strftime(buf[1], MAX_LENGTH, time_format, timeinfo[1]);
|
strftime(buf[1], MAX_LENGTH, time_format, timeinfo[1]);
|
||||||
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;
|
|
||||||
|
|
||||||
ifstream Aifs(fp1.c_str());
|
ifstream Aifs(fp1.c_str());
|
||||||
ifstream Bifs(fp2.c_str());
|
ifstream Bifs(fp2.c_str());
|
||||||
elem buf;
|
elem buf;
|
||||||
sequence ALines, BLines;
|
sequence ALines, BLines;
|
||||||
|
|
||||||
while(getline(Aifs, buf)){
|
while (getline(Aifs, buf)) {
|
||||||
ALines.push_back(buf);
|
ALines.push_back(buf);
|
||||||
}
|
}
|
||||||
while(getline(Bifs, buf)){
|
while (getline(Bifs, buf)) {
|
||||||
BLines.push_back(buf);
|
BLines.push_back(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
Diff< elem > diff(ALines, BLines);
|
Diff<elem> diff(ALines, BLines);
|
||||||
diff.onHuge();
|
diff.onHuge();
|
||||||
//diff.onUnserious();
|
// diff.onUnserious();
|
||||||
diff.compose();
|
diff.compose();
|
||||||
|
|
||||||
// type unihunk definition test
|
// type unihunk definition test
|
||||||
uniHunk< sesElem > hunk;
|
uniHunk<sesElem> hunk;
|
||||||
|
|
||||||
if (diff.getEditDistance() > 0) {
|
if (diff.getEditDistance() > 0) {
|
||||||
showStats(fp1, fp2); // show file info
|
showStats(fp1, fp2); // show file info
|
||||||
}
|
}
|
||||||
|
|
||||||
diff.composeUnifiedHunks();
|
diff.composeUnifiedHunks();
|
||||||
diff.printUnifiedFormat();
|
diff.printUnifiedFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
if (isFewArgs(argc)) {
|
||||||
|
cerr << "Too few arguments." << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
string s1(argv[1]);
|
||||||
{
|
string s2(argv[2]);
|
||||||
if (isFewArgs(argc)) {
|
bool fileExist = true;
|
||||||
cerr << "Too few arguments." << endl;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
string s1(argv[1]);
|
if (!isFileExist(s1)) {
|
||||||
string s2(argv[2]);
|
cerr << s1 << " is invalid." << endl;
|
||||||
bool fileExist = true;
|
fileExist = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isFileExist(s1)) {
|
if (!isFileExist(s2)) {
|
||||||
cerr << s1 << " is invalid." << endl;
|
cerr << s2 << " is invalid." << endl;
|
||||||
fileExist = false;
|
fileExist = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFileExist(s2)) {
|
if (!fileExist) {
|
||||||
cerr << s2 << " is invalid." << endl;
|
return -1;
|
||||||
fileExist = false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!fileExist) {
|
unifiedDiff(s1, s2);
|
||||||
return -1;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
unifiedDiff(s1, s2);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
|
|
||||||
@ -8,33 +8,33 @@ using namespace std;
|
|||||||
|
|
||||||
using dtl::Diff;
|
using dtl::Diff;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef char elem;
|
typedef char elem;
|
||||||
typedef string sequence;
|
typedef string sequence;
|
||||||
|
|
||||||
sequence A(argv[1]);
|
sequence A(argv[1]);
|
||||||
sequence B(argv[2]);
|
sequence B(argv[2]);
|
||||||
|
|
||||||
Diff<elem, sequence > d(A, B);
|
Diff<elem, sequence> d(A, B);
|
||||||
d.compose();
|
d.compose();
|
||||||
d.composeUnifiedHunks();
|
d.composeUnifiedHunks();
|
||||||
|
|
||||||
// editDistance
|
// editDistance
|
||||||
cout << "editDistance:" << d.getEditDistance() << endl;
|
cout << "editDistance:" << d.getEditDistance() << endl;
|
||||||
|
|
||||||
// Longest Common Subsequence
|
// Longest Common Subsequence
|
||||||
vector<elem> lcs_v = d.getLcsVec();
|
vector<elem> lcs_v = d.getLcsVec();
|
||||||
sequence lcs_s(lcs_v.begin(), lcs_v.end());
|
sequence lcs_s(lcs_v.begin(), lcs_v.end());
|
||||||
cout << "LCS:" << lcs_s << endl;
|
cout << "LCS:" << lcs_s << endl;
|
||||||
|
|
||||||
// print Unified Format
|
// print Unified Format
|
||||||
d.printUnifiedFormat();
|
d.printUnifiedFormat();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,83 +1,80 @@
|
|||||||
#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>) typedef struct case_t {
|
||||||
dtl_test_typedefs(int, vector< int >)
|
sequence A;
|
||||||
typedef struct case_t {
|
sequence B;
|
||||||
sequence A;
|
size_t editdis;
|
||||||
sequence B;
|
elemVec lcs_v;
|
||||||
size_t editdis;
|
sequence lcs_s;
|
||||||
elemVec lcs_v;
|
sesElemVec ses_seq;
|
||||||
sequence lcs_s;
|
uniHunkVec hunk_v;
|
||||||
sesElemVec ses_seq;
|
size_t editdis_ses;
|
||||||
uniHunkVec hunk_v;
|
size_t editdis_uni;
|
||||||
size_t editdis_ses;
|
string path_rses;
|
||||||
size_t editdis_uni;
|
string path_rhunks;
|
||||||
string path_rses;
|
} case_t;
|
||||||
string path_rhunks;
|
typedef vector<case_t> caseVec;
|
||||||
} case_t;
|
caseVec cases;
|
||||||
typedef vector< case_t > caseVec;
|
|
||||||
caseVec cases;
|
|
||||||
|
|
||||||
case_t createCase (const sequence a, const sequence b, string test_name) {
|
case_t createCase(const sequence a, const sequence b, string test_name) {
|
||||||
case_t c;
|
case_t c;
|
||||||
string diff_name("intdiff");
|
string diff_name("intdiff");
|
||||||
Diff< elem > diff(a, b);
|
Diff<elem> diff(a, b);
|
||||||
diff.compose();
|
diff.compose();
|
||||||
diff.composeUnifiedHunks();
|
diff.composeUnifiedHunks();
|
||||||
|
|
||||||
if (test_name != "") {
|
if (test_name != "") {
|
||||||
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);
|
||||||
c.editdis_ses = cal_diff_uni(path_lses, path_rses);
|
create_file<elem, sequence, Compare<elem>>(path_rhunks, diff,
|
||||||
c.editdis_uni = cal_diff_uni(path_lhunks, path_rhunks);
|
TYPE_DIFF_UNI);
|
||||||
c.path_rses = path_rses;
|
c.editdis_ses = cal_diff_uni(path_lses, path_rses);
|
||||||
c.path_rhunks = path_rhunks;
|
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();
|
|
||||||
c.lcs_v = diff.getLcsVec();
|
|
||||||
c.ses_seq = diff.getSes().getSequence();
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUp() {
|
c.A = a;
|
||||||
cases.push_back(createCase(sequence(0), sequence(0), "diff_test0"));
|
c.B = b;
|
||||||
sequence B1;
|
c.editdis = diff.getEditDistance();
|
||||||
B1.push_back(1);
|
c.lcs_v = diff.getLcsVec();
|
||||||
cases.push_back(createCase(sequence(0), B1, "diff_test1"));
|
c.ses_seq = diff.getSes().getSequence();
|
||||||
sequence A2;
|
return c;
|
||||||
A2.push_back(1);
|
}
|
||||||
cases.push_back(createCase(A2, sequence(0), "diff_test2"));
|
|
||||||
int a4[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
|
||||||
int b4[] = {3, 5, 1, 4, 5, 1, 7, 9, 6, 10};
|
|
||||||
int a4siz = sizeof(a4) / sizeof(int);
|
|
||||||
int b4siz = sizeof(b4) / sizeof(int);
|
|
||||||
sequence A4(&a4[0], &a4[a4siz]);
|
|
||||||
sequence B4(&b4[0], &b4[b4siz]);
|
|
||||||
cases.push_back(createCase(A4, B4, "diff_test3"));
|
|
||||||
int a5[] = {1, 2, 3, 4, 5};
|
|
||||||
int b5[] = {3, 5, 1, 4, 5};
|
|
||||||
int a5siz = sizeof(a5) / sizeof(int);
|
|
||||||
int b5siz = sizeof(b5) / sizeof(int);
|
|
||||||
sequence A5(&a5[0], &a5[a5siz]);
|
|
||||||
sequence B5(&b5[0], &b5[b5siz]);
|
|
||||||
cases.push_back(createCase(A5, B5, "diff_test4"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void TearDown () {
|
void SetUp() {
|
||||||
for_each(cases.begin(), cases.end(), Remover< case_t >());
|
cases.push_back(createCase(sequence(0), sequence(0), "diff_test0"));
|
||||||
}
|
sequence B1;
|
||||||
|
B1.push_back(1);
|
||||||
|
cases.push_back(createCase(sequence(0), B1, "diff_test1"));
|
||||||
|
sequence A2;
|
||||||
|
A2.push_back(1);
|
||||||
|
cases.push_back(createCase(A2, sequence(0), "diff_test2"));
|
||||||
|
int a4[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
|
int b4[] = {3, 5, 1, 4, 5, 1, 7, 9, 6, 10};
|
||||||
|
int a4siz = sizeof(a4) / sizeof(int);
|
||||||
|
int b4siz = sizeof(b4) / sizeof(int);
|
||||||
|
sequence A4(&a4[0], &a4[a4siz]);
|
||||||
|
sequence B4(&b4[0], &b4[b4siz]);
|
||||||
|
cases.push_back(createCase(A4, B4, "diff_test3"));
|
||||||
|
int a5[] = {1, 2, 3, 4, 5};
|
||||||
|
int b5[] = {3, 5, 1, 4, 5};
|
||||||
|
int a5siz = sizeof(a5) / sizeof(int);
|
||||||
|
int b5siz = sizeof(b5) / sizeof(int);
|
||||||
|
sequence A5(&a5[0], &a5[a5siz]);
|
||||||
|
sequence B5(&b5[0], &b5[b5siz]);
|
||||||
|
cases.push_back(createCase(A5, B5, "diff_test4"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() { for_each(cases.begin(), cases.end(), Remover<case_t>()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,58 +84,58 @@ protected :
|
|||||||
* - LCS
|
* - LCS
|
||||||
* - SES
|
* - SES
|
||||||
*/
|
*/
|
||||||
TEST_F (Intdifftest, diff_test0) {
|
TEST_F(Intdifftest, diff_test0) {
|
||||||
EXPECT_EQ(0, cases[0].editdis);
|
EXPECT_EQ(0, cases[0].editdis);
|
||||||
|
|
||||||
EXPECT_TRUE(cases[0].lcs_v.empty());
|
EXPECT_TRUE(cases[0].lcs_v.empty());
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[0].editdis_ses);
|
ASSERT_EQ(0, cases[0].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[0].editdis_uni);
|
ASSERT_EQ(0, cases[0].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Intdifftest, diff_test1) {
|
TEST_F(Intdifftest, diff_test1) {
|
||||||
EXPECT_EQ(1, cases[1].editdis);
|
EXPECT_EQ(1, cases[1].editdis);
|
||||||
|
|
||||||
EXPECT_TRUE(cases[1].lcs_v.empty());
|
EXPECT_TRUE(cases[1].lcs_v.empty());
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[1].editdis_ses);
|
ASSERT_EQ(0, cases[1].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[1].editdis_uni);
|
ASSERT_EQ(0, cases[1].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Intdifftest, diff_test2) {
|
TEST_F(Intdifftest, diff_test2) {
|
||||||
EXPECT_EQ(1, cases[2].editdis);
|
EXPECT_EQ(1, cases[2].editdis);
|
||||||
|
|
||||||
EXPECT_TRUE(cases[2].lcs_v.empty());
|
EXPECT_TRUE(cases[2].lcs_v.empty());
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[2].editdis_ses);
|
ASSERT_EQ(0, cases[2].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[2].editdis_uni);
|
ASSERT_EQ(0, cases[2].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Intdifftest, diff_test3) {
|
TEST_F(Intdifftest, diff_test3) {
|
||||||
EXPECT_EQ(8, cases[3].editdis);
|
EXPECT_EQ(8, cases[3].editdis);
|
||||||
|
|
||||||
EXPECT_EQ(3, cases[3].lcs_v[0]);
|
EXPECT_EQ(3, cases[3].lcs_v[0]);
|
||||||
EXPECT_EQ(4, cases[3].lcs_v[1]);
|
EXPECT_EQ(4, cases[3].lcs_v[1]);
|
||||||
EXPECT_EQ(5, cases[3].lcs_v[2]);
|
EXPECT_EQ(5, cases[3].lcs_v[2]);
|
||||||
EXPECT_EQ(7, cases[3].lcs_v[3]);
|
EXPECT_EQ(7, cases[3].lcs_v[3]);
|
||||||
EXPECT_EQ(9, cases[3].lcs_v[4]);
|
EXPECT_EQ(9, cases[3].lcs_v[4]);
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[3].editdis_ses);
|
ASSERT_EQ(0, cases[3].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[3].editdis_uni);
|
ASSERT_EQ(0, cases[3].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Intdifftest, diff_test4) {
|
TEST_F(Intdifftest, diff_test4) {
|
||||||
EXPECT_EQ(4, cases[4].editdis);
|
EXPECT_EQ(4, cases[4].editdis);
|
||||||
|
|
||||||
EXPECT_EQ(3, cases[4].lcs_v[0]);
|
EXPECT_EQ(3, cases[4].lcs_v[0]);
|
||||||
EXPECT_EQ(4, cases[4].lcs_v[1]);
|
EXPECT_EQ(4, cases[4].lcs_v[1]);
|
||||||
EXPECT_EQ(5, cases[4].lcs_v[2]);
|
EXPECT_EQ(5, cases[4].lcs_v[2]);
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[4].editdis_ses);
|
ASSERT_EQ(0, cases[4].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, cases[4].editdis_uni);
|
ASSERT_EQ(0, cases[4].editdis_uni);
|
||||||
}
|
}
|
||||||
|
@ -1,101 +1,103 @@
|
|||||||
#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>) typedef struct case_t {
|
||||||
dtl_test_typedefs(string, vector<elem>)
|
sequence A;
|
||||||
typedef struct case_t {
|
sequence B;
|
||||||
sequence A;
|
sesElemVec expected;
|
||||||
sequence B;
|
sesElemVec ses_seq;
|
||||||
sesElemVec expected;
|
} case_t;
|
||||||
sesElemVec ses_seq;
|
typedef vector<case_t> caseVec;
|
||||||
} case_t;
|
|
||||||
typedef vector< case_t > caseVec;
|
|
||||||
|
|
||||||
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,
|
||||||
case_t c;
|
string test_name) {
|
||||||
elemVec lcs_v;
|
case_t c;
|
||||||
string diff_name("objdiff");
|
elemVec lcs_v;
|
||||||
|
string diff_name("objdiff");
|
||||||
|
|
||||||
Diff< elem, sequence, comparator > diff(a, b, true);
|
Diff<elem, sequence, comparator> diff(a, b, true);
|
||||||
|
|
||||||
diff.compose();
|
diff.compose();
|
||||||
|
|
||||||
c.A = a;
|
c.A = a;
|
||||||
c.B = b;
|
c.B = b;
|
||||||
c.ses_seq = diff.getSes().getSequence();
|
c.ses_seq = diff.getSes().getSequence();
|
||||||
c.expected = ses;
|
c.expected = ses;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetUp(void) {
|
||||||
|
{
|
||||||
|
string array1[] = {"the", "quick", "brown"};
|
||||||
|
string array2[] = {"The", "Quick", "Fox"};
|
||||||
|
|
||||||
|
sequence A(array1, array1 + (sizeof(array1) / sizeof(array1[0])));
|
||||||
|
sequence B(array2, array2 + (sizeof(array2) / sizeof(array2[0])));
|
||||||
|
|
||||||
|
dtl::Ses<elem> ses;
|
||||||
|
ses.addSequence("the", 1, 1, dtl::SES_COMMON);
|
||||||
|
ses.addSequence("quick", 2, 2, dtl::SES_COMMON);
|
||||||
|
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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUp(void) {
|
{
|
||||||
{
|
string array1[] = {"b", "c", "e", "g"};
|
||||||
string array1[] = {"the", "quick", "brown"};
|
string array2[] = {"a", "d", "e", "f", "h"};
|
||||||
string array2[] = {"The", "Quick", "Fox"};
|
|
||||||
|
|
||||||
sequence A(array1, array1 + (sizeof(array1) / sizeof(array1[0])));
|
sequence A(array1, array1 + (sizeof(array1) / sizeof(array1[0])));
|
||||||
sequence B(array2, array2 + (sizeof(array2) / sizeof(array2[0])));
|
sequence B(array2, array2 + (sizeof(array2) / sizeof(array2[0])));
|
||||||
|
|
||||||
dtl::Ses< elem > ses;
|
dtl::Ses<elem> ses;
|
||||||
ses.addSequence("the", 1, 1, dtl::SES_COMMON);
|
ses.addSequence("b", 1, 0, dtl::SES_DELETE);
|
||||||
ses.addSequence("quick", 2, 2, dtl::SES_COMMON);
|
ses.addSequence("c", 2, 0, dtl::SES_DELETE);
|
||||||
ses.addSequence("brown", 3, 0, dtl::SES_DELETE);
|
ses.addSequence("a", 0, 1, dtl::SES_ADD);
|
||||||
ses.addSequence("Fox", 0, 3, dtl::SES_ADD);
|
ses.addSequence("d", 0, 2, dtl::SES_ADD);
|
||||||
|
ses.addSequence("e", 3, 3, dtl::SES_COMMON);
|
||||||
|
ses.addSequence("g", 4, 0, dtl::SES_DELETE);
|
||||||
|
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_test0_pattern"));
|
obj_diff_cases.push_back(createCase<StringCaseInsensitive>(
|
||||||
}
|
A, B, ses.getSequence(), "objdiff_test1_unswapped"));
|
||||||
|
|
||||||
{
|
|
||||||
string array1[] = {"b", "c", "e", "g"};
|
|
||||||
string array2[] = {"a", "d", "e", "f", "h"};
|
|
||||||
|
|
||||||
sequence A(array1, array1 + (sizeof(array1) / sizeof(array1[0])));
|
|
||||||
sequence B(array2, array2 + (sizeof(array2) / sizeof(array2[0])));
|
|
||||||
|
|
||||||
dtl::Ses< elem > ses;
|
|
||||||
ses.addSequence("b", 1, 0, dtl::SES_DELETE);
|
|
||||||
ses.addSequence("c", 2, 0, dtl::SES_DELETE);
|
|
||||||
ses.addSequence("a", 0, 1, dtl::SES_ADD);
|
|
||||||
ses.addSequence("d", 0, 2, dtl::SES_ADD);
|
|
||||||
ses.addSequence("e", 3, 3, dtl::SES_COMMON);
|
|
||||||
ses.addSequence("g", 4, 0, dtl::SES_DELETE);
|
|
||||||
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"));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
string array1[] = {"a", "d", "e", "f", "h"};
|
|
||||||
string array2[] = {"b", "c", "e", "g"};
|
|
||||||
|
|
||||||
sequence A(array1, array1 + (sizeof(array1) / sizeof(array1[0])));
|
|
||||||
sequence B(array2, array2 + (sizeof(array2) / sizeof(array2[0])));
|
|
||||||
|
|
||||||
dtl::Ses< elem > ses;
|
|
||||||
ses.addSequence("a", 1, 0, dtl::SES_DELETE);
|
|
||||||
ses.addSequence("d", 2, 0, dtl::SES_DELETE);
|
|
||||||
ses.addSequence("b", 0, 1, dtl::SES_ADD);
|
|
||||||
ses.addSequence("c", 0, 2, dtl::SES_ADD);
|
|
||||||
ses.addSequence("e", 3, 3, dtl::SES_COMMON);
|
|
||||||
ses.addSequence("f", 4, 0, dtl::SES_DELETE);
|
|
||||||
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"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
string array1[] = {"a", "d", "e", "f", "h"};
|
||||||
|
string array2[] = {"b", "c", "e", "g"};
|
||||||
|
|
||||||
void TearDown () {
|
sequence A(array1, array1 + (sizeof(array1) / sizeof(array1[0])));
|
||||||
//for_each(obj_diff_cases.begin(), obj_diff_cases.end(), Remover< case_t >());
|
sequence B(array2, array2 + (sizeof(array2) / sizeof(array2[0])));
|
||||||
|
|
||||||
|
dtl::Ses<elem> ses;
|
||||||
|
ses.addSequence("a", 1, 0, dtl::SES_DELETE);
|
||||||
|
ses.addSequence("d", 2, 0, dtl::SES_DELETE);
|
||||||
|
ses.addSequence("b", 0, 1, dtl::SES_ADD);
|
||||||
|
ses.addSequence("c", 0, 2, dtl::SES_ADD);
|
||||||
|
ses.addSequence("e", 3, 3, dtl::SES_COMMON);
|
||||||
|
ses.addSequence("f", 4, 0, dtl::SES_DELETE);
|
||||||
|
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"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() {
|
||||||
|
// for_each(obj_diff_cases.begin(), obj_diff_cases.end(), Remover< case_t
|
||||||
|
// >());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Objdifftest
|
* Objdifftest
|
||||||
* check list:
|
* check list:
|
||||||
@ -103,14 +105,14 @@ protected :
|
|||||||
* - Indepence of results from swapping
|
* - Indepence of results from swapping
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TEST_F (Objdifftest, objdiff_test0_pattern) {
|
TEST_F(Objdifftest, objdiff_test0_pattern) {
|
||||||
EXPECT_EQ(obj_diff_cases[0].expected, obj_diff_cases[0].ses_seq);
|
EXPECT_EQ(obj_diff_cases[0].expected, obj_diff_cases[0].ses_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Objdifftest, objdiff_test1_unswapped) {
|
TEST_F(Objdifftest, objdiff_test1_unswapped) {
|
||||||
EXPECT_EQ(obj_diff_cases[1].expected, obj_diff_cases[1].ses_seq);
|
EXPECT_EQ(obj_diff_cases[1].expected, obj_diff_cases[1].ses_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Objdifftest, objdiff_test2_swapped) {
|
TEST_F(Objdifftest, objdiff_test2_swapped) {
|
||||||
EXPECT_EQ(obj_diff_cases[2].expected, obj_diff_cases[2].ses_seq);
|
EXPECT_EQ(obj_diff_cases[2].expected, obj_diff_cases[2].ses_seq);
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,98 @@
|
|||||||
#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) typedef struct case_t {
|
||||||
dtl_test_typedefs(char, string)
|
sequence A;
|
||||||
typedef struct case_t {
|
sequence B;
|
||||||
sequence A;
|
Diff<elem, sequence> diff;
|
||||||
sequence B;
|
} case_t;
|
||||||
Diff< elem, sequence > diff;
|
typedef vector<case_t> caseVec;
|
||||||
} case_t;
|
|
||||||
typedef vector< case_t > caseVec;
|
|
||||||
|
|
||||||
caseVec cases;
|
caseVec cases;
|
||||||
|
|
||||||
case_t createCase (sequence a, sequence b) {
|
case_t createCase(sequence a, sequence b) {
|
||||||
case_t c;
|
case_t c;
|
||||||
c.A = a;
|
c.A = a;
|
||||||
c.B = b;
|
c.B = b;
|
||||||
c.diff = Diff< elem, sequence >(a, b);
|
c.diff = Diff<elem, sequence>(a, b);
|
||||||
c.diff.compose();
|
c.diff.compose();
|
||||||
c.diff.composeUnifiedHunks();
|
c.diff.composeUnifiedHunks();
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUp() {
|
void SetUp() {
|
||||||
cases.push_back(createCase("abc", "abd")); // 0
|
cases.push_back(createCase("abc", "abd")); // 0
|
||||||
cases.push_back(createCase("acbdeacbed", "acebdabbabed")); // 1
|
cases.push_back(createCase("acbdeacbed", "acebdabbabed")); // 1
|
||||||
cases.push_back(createCase("abcdef", "dacfea")); // 2
|
cases.push_back(createCase("abcdef", "dacfea")); // 2
|
||||||
cases.push_back(createCase("abcbda", "bdcaba")); // 3
|
cases.push_back(createCase("abcbda", "bdcaba")); // 3
|
||||||
cases.push_back(createCase("bokko", "bokkko")); // 4
|
cases.push_back(createCase("bokko", "bokkko")); // 4
|
||||||
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(
|
||||||
"3abcdef4976fd86ouofita67t85r876e5e746578tgliuhopoqqabcdef")); // 8
|
"abcdefq3wefarhgorequgho4euhfteowauhfwehogfewrquhoi23hroewhoahfotrhguoi"
|
||||||
cases.push_back(createCase("abcqqqeqqqccc", "abdqqqeqqqddd")); // 9
|
"ewahrgqqabcdef",
|
||||||
cases.push_back(createCase("aaaaaaaaaaaaa>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>aaaadsafabcaaaaaaaaaaaaaaaaaaewaaabdaaaaaabbb", "aaaaaaaaaaaaaaadasfdsafsadasdafbaaaaaaaaaaaaaaaaaeaaaaaaaaaae&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&saaabcaaaaaaccc")); // 10
|
"3abcdef4976fd86ouofita67t85r876e5e746578tgliuhopoqqabcdef")); // 8
|
||||||
}
|
cases.push_back(createCase("abcqqqeqqqccc", "abdqqqeqqqddd")); // 9
|
||||||
|
cases.push_back(createCase(
|
||||||
void TearDown () {}
|
"aaaaaaaaaaaaa>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||||
|
"aaaadsafabcaaaaaaaaaaaaaaaaaaewaaabdaaaaaabbb",
|
||||||
|
"aaaaaaaaaaaaaaadasfdsafsadasdafbaaaaaaaaaaaaaaaaaeaaaaaaaaaae&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
||||||
|
"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&saaabcaaaaaaccc")); // 10
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,57 +101,57 @@ protected :
|
|||||||
* - patch function
|
* - patch function
|
||||||
* - uniPatch function
|
* - uniPatch function
|
||||||
*/
|
*/
|
||||||
TEST_F (Patchtest, patch_test0) {
|
TEST_F(Patchtest, patch_test0) {
|
||||||
ASSERT_EQ(cases[0].B, cases[0].diff.patch(cases[0].A));
|
ASSERT_EQ(cases[0].B, cases[0].diff.patch(cases[0].A));
|
||||||
ASSERT_EQ(cases[0].B, cases[0].diff.uniPatch(cases[0].A));
|
ASSERT_EQ(cases[0].B, cases[0].diff.uniPatch(cases[0].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test1) {
|
TEST_F(Patchtest, patch_test1) {
|
||||||
ASSERT_EQ(cases[1].B, cases[1].diff.patch(cases[1].A));
|
ASSERT_EQ(cases[1].B, cases[1].diff.patch(cases[1].A));
|
||||||
ASSERT_EQ(cases[1].B, cases[1].diff.uniPatch(cases[1].A));
|
ASSERT_EQ(cases[1].B, cases[1].diff.uniPatch(cases[1].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test2) {
|
TEST_F(Patchtest, patch_test2) {
|
||||||
ASSERT_EQ(cases[2].B, cases[2].diff.patch(cases[2].A));
|
ASSERT_EQ(cases[2].B, cases[2].diff.patch(cases[2].A));
|
||||||
ASSERT_EQ(cases[2].B, cases[2].diff.uniPatch(cases[2].A));
|
ASSERT_EQ(cases[2].B, cases[2].diff.uniPatch(cases[2].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test3) {
|
TEST_F(Patchtest, patch_test3) {
|
||||||
ASSERT_EQ(cases[3].B, cases[3].diff.patch(cases[3].A));
|
ASSERT_EQ(cases[3].B, cases[3].diff.patch(cases[3].A));
|
||||||
ASSERT_EQ(cases[3].B, cases[3].diff.uniPatch(cases[3].A));
|
ASSERT_EQ(cases[3].B, cases[3].diff.uniPatch(cases[3].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test4) {
|
TEST_F(Patchtest, patch_test4) {
|
||||||
ASSERT_EQ(cases[4].B, cases[4].diff.patch(cases[4].A));
|
ASSERT_EQ(cases[4].B, cases[4].diff.patch(cases[4].A));
|
||||||
ASSERT_EQ(cases[4].B, cases[4].diff.uniPatch(cases[4].A));
|
ASSERT_EQ(cases[4].B, cases[4].diff.uniPatch(cases[4].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test5) {
|
TEST_F(Patchtest, patch_test5) {
|
||||||
ASSERT_EQ(cases[5].B, cases[5].diff.patch(cases[5].A));
|
ASSERT_EQ(cases[5].B, cases[5].diff.patch(cases[5].A));
|
||||||
ASSERT_EQ(cases[5].B, cases[5].diff.uniPatch(cases[5].A));
|
ASSERT_EQ(cases[5].B, cases[5].diff.uniPatch(cases[5].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test6) {
|
TEST_F(Patchtest, patch_test6) {
|
||||||
ASSERT_EQ(cases[6].B, cases[6].diff.patch(cases[6].A));
|
ASSERT_EQ(cases[6].B, cases[6].diff.patch(cases[6].A));
|
||||||
ASSERT_EQ(cases[6].B, cases[6].diff.uniPatch(cases[6].A));
|
ASSERT_EQ(cases[6].B, cases[6].diff.uniPatch(cases[6].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test7) {
|
TEST_F(Patchtest, patch_test7) {
|
||||||
ASSERT_EQ(cases[7].B, cases[7].diff.patch(cases[7].A));
|
ASSERT_EQ(cases[7].B, cases[7].diff.patch(cases[7].A));
|
||||||
ASSERT_EQ(cases[7].B, cases[7].diff.uniPatch(cases[7].A));
|
ASSERT_EQ(cases[7].B, cases[7].diff.uniPatch(cases[7].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test8) {
|
TEST_F(Patchtest, patch_test8) {
|
||||||
ASSERT_EQ(cases[8].B, cases[8].diff.patch(cases[8].A));
|
ASSERT_EQ(cases[8].B, cases[8].diff.patch(cases[8].A));
|
||||||
ASSERT_EQ(cases[8].B, cases[8].diff.uniPatch(cases[8].A));
|
ASSERT_EQ(cases[8].B, cases[8].diff.uniPatch(cases[8].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test9) {
|
TEST_F(Patchtest, patch_test9) {
|
||||||
ASSERT_EQ(cases[9].B, cases[9].diff.patch(cases[9].A));
|
ASSERT_EQ(cases[9].B, cases[9].diff.patch(cases[9].A));
|
||||||
ASSERT_EQ(cases[9].B, cases[9].diff.uniPatch(cases[9].A));
|
ASSERT_EQ(cases[9].B, cases[9].diff.uniPatch(cases[9].A));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Patchtest, patch_test10) {
|
TEST_F(Patchtest, patch_test10) {
|
||||||
ASSERT_EQ(cases[10].B, cases[10].diff.patch(cases[10].A));
|
ASSERT_EQ(cases[10].B, cases[10].diff.patch(cases[10].A));
|
||||||
ASSERT_EQ(cases[10].B, cases[10].diff.uniPatch(cases[10].A));
|
ASSERT_EQ(cases[10].B, cases[10].diff.uniPatch(cases[10].A));
|
||||||
}
|
}
|
||||||
|
@ -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,71 +1,95 @@
|
|||||||
#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) typedef struct case_t {
|
||||||
dtl_test_typedefs(char, string)
|
sequence S;
|
||||||
typedef struct case_t {
|
bool is_merge_success;
|
||||||
sequence S;
|
sequence merged_seq;
|
||||||
bool is_merge_success;
|
} case_t;
|
||||||
sequence merged_seq;
|
typedef vector<case_t> caseVec;
|
||||||
} case_t;
|
|
||||||
typedef vector< case_t > caseVec;
|
|
||||||
|
|
||||||
caseVec merge_cases;
|
caseVec merge_cases;
|
||||||
caseVec detect_cases;
|
caseVec detect_cases;
|
||||||
caseVec custom_cases;
|
caseVec custom_cases;
|
||||||
|
|
||||||
template < typename comparator >
|
template <typename comparator>
|
||||||
case_t createCase (sequence a, sequence b, sequence c, sequence s) {
|
case_t createCase(sequence a, sequence b, sequence c, sequence s) {
|
||||||
Diff3< elem, sequence, comparator > diff3(a, b, c);
|
Diff3<elem, sequence, comparator> diff3(a, b, c);
|
||||||
case_t ct;
|
case_t ct;
|
||||||
|
|
||||||
diff3.compose();
|
diff3.compose();
|
||||||
|
|
||||||
ct.S = s;
|
ct.S = s;
|
||||||
ct.is_merge_success = diff3.merge();
|
ct.is_merge_success = diff3.merge();
|
||||||
ct.merged_seq = diff3.getMergedSequence();
|
ct.merged_seq = diff3.getMergedSequence();
|
||||||
return ct;
|
return ct;
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,135 +98,135 @@ protected :
|
|||||||
* - merge function
|
* - merge function
|
||||||
* - detect confliction
|
* - detect confliction
|
||||||
*/
|
*/
|
||||||
TEST_F (Strdiff3test, merge_test0) {
|
TEST_F(Strdiff3test, merge_test0) {
|
||||||
ASSERT_TRUE(merge_cases[0].is_merge_success);
|
ASSERT_TRUE(merge_cases[0].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[0].S, merge_cases[0].merged_seq);
|
ASSERT_EQ(merge_cases[0].S, merge_cases[0].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test1) {
|
TEST_F(Strdiff3test, merge_test1) {
|
||||||
ASSERT_TRUE(merge_cases[1].is_merge_success);
|
ASSERT_TRUE(merge_cases[1].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[1].S, merge_cases[1].merged_seq);
|
ASSERT_EQ(merge_cases[1].S, merge_cases[1].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test2) {
|
TEST_F(Strdiff3test, merge_test2) {
|
||||||
ASSERT_TRUE(merge_cases[2].is_merge_success);
|
ASSERT_TRUE(merge_cases[2].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[2].S, merge_cases[2].merged_seq);
|
ASSERT_EQ(merge_cases[2].S, merge_cases[2].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test3) {
|
TEST_F(Strdiff3test, merge_test3) {
|
||||||
ASSERT_TRUE(merge_cases[3].is_merge_success);
|
ASSERT_TRUE(merge_cases[3].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[3].S, merge_cases[3].merged_seq);
|
ASSERT_EQ(merge_cases[3].S, merge_cases[3].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test4) {
|
TEST_F(Strdiff3test, merge_test4) {
|
||||||
ASSERT_TRUE(merge_cases[4].is_merge_success);
|
ASSERT_TRUE(merge_cases[4].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[4].S, merge_cases[4].merged_seq);
|
ASSERT_EQ(merge_cases[4].S, merge_cases[4].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test5) {
|
TEST_F(Strdiff3test, merge_test5) {
|
||||||
ASSERT_TRUE(merge_cases[5].is_merge_success);
|
ASSERT_TRUE(merge_cases[5].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[5].S, merge_cases[5].merged_seq);
|
ASSERT_EQ(merge_cases[5].S, merge_cases[5].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test6) {
|
TEST_F(Strdiff3test, merge_test6) {
|
||||||
ASSERT_TRUE(merge_cases[6].is_merge_success);
|
ASSERT_TRUE(merge_cases[6].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[6].S, merge_cases[6].merged_seq);
|
ASSERT_EQ(merge_cases[6].S, merge_cases[6].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test7) {
|
TEST_F(Strdiff3test, merge_test7) {
|
||||||
ASSERT_TRUE(merge_cases[7].is_merge_success);
|
ASSERT_TRUE(merge_cases[7].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[7].S, merge_cases[7].merged_seq);
|
ASSERT_EQ(merge_cases[7].S, merge_cases[7].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test8) {
|
TEST_F(Strdiff3test, merge_test8) {
|
||||||
ASSERT_TRUE(merge_cases[8].is_merge_success);
|
ASSERT_TRUE(merge_cases[8].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[8].S, merge_cases[8].merged_seq);
|
ASSERT_EQ(merge_cases[8].S, merge_cases[8].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test9) {
|
TEST_F(Strdiff3test, merge_test9) {
|
||||||
ASSERT_TRUE(merge_cases[9].is_merge_success);
|
ASSERT_TRUE(merge_cases[9].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[9].S, merge_cases[9].merged_seq);
|
ASSERT_EQ(merge_cases[9].S, merge_cases[9].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test10) {
|
TEST_F(Strdiff3test, merge_test10) {
|
||||||
ASSERT_TRUE(merge_cases[10].is_merge_success);
|
ASSERT_TRUE(merge_cases[10].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[10].S, merge_cases[10].merged_seq);
|
ASSERT_EQ(merge_cases[10].S, merge_cases[10].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test11) {
|
TEST_F(Strdiff3test, merge_test11) {
|
||||||
ASSERT_TRUE(merge_cases[11].is_merge_success);
|
ASSERT_TRUE(merge_cases[11].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[11].S, merge_cases[11].merged_seq);
|
ASSERT_EQ(merge_cases[11].S, merge_cases[11].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test12) {
|
TEST_F(Strdiff3test, merge_test12) {
|
||||||
ASSERT_TRUE(merge_cases[12].is_merge_success);
|
ASSERT_TRUE(merge_cases[12].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[12].S, merge_cases[12].merged_seq);
|
ASSERT_EQ(merge_cases[12].S, merge_cases[12].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test13) {
|
TEST_F(Strdiff3test, merge_test13) {
|
||||||
ASSERT_TRUE(merge_cases[13].is_merge_success);
|
ASSERT_TRUE(merge_cases[13].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[13].S, merge_cases[13].merged_seq);
|
ASSERT_EQ(merge_cases[13].S, merge_cases[13].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test14) {
|
TEST_F(Strdiff3test, merge_test14) {
|
||||||
ASSERT_TRUE(merge_cases[14].is_merge_success);
|
ASSERT_TRUE(merge_cases[14].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[14].S, merge_cases[14].merged_seq);
|
ASSERT_EQ(merge_cases[14].S, merge_cases[14].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test15) {
|
TEST_F(Strdiff3test, merge_test15) {
|
||||||
ASSERT_TRUE(merge_cases[15].is_merge_success);
|
ASSERT_TRUE(merge_cases[15].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[15].S, merge_cases[15].merged_seq);
|
ASSERT_EQ(merge_cases[15].S, merge_cases[15].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test16) {
|
TEST_F(Strdiff3test, merge_test16) {
|
||||||
ASSERT_TRUE(merge_cases[16].is_merge_success);
|
ASSERT_TRUE(merge_cases[16].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[16].S, merge_cases[16].merged_seq);
|
ASSERT_EQ(merge_cases[16].S, merge_cases[16].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test17) {
|
TEST_F(Strdiff3test, merge_test17) {
|
||||||
ASSERT_TRUE(merge_cases[17].is_merge_success);
|
ASSERT_TRUE(merge_cases[17].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[17].S, merge_cases[17].merged_seq);
|
ASSERT_EQ(merge_cases[17].S, merge_cases[17].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test18) {
|
TEST_F(Strdiff3test, merge_test18) {
|
||||||
ASSERT_TRUE(merge_cases[18].is_merge_success);
|
ASSERT_TRUE(merge_cases[18].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[18].S, merge_cases[18].merged_seq);
|
ASSERT_EQ(merge_cases[18].S, merge_cases[18].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test19) {
|
TEST_F(Strdiff3test, merge_test19) {
|
||||||
ASSERT_TRUE(merge_cases[19].is_merge_success);
|
ASSERT_TRUE(merge_cases[19].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[19].S, merge_cases[19].merged_seq);
|
ASSERT_EQ(merge_cases[19].S, merge_cases[19].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test20) {
|
TEST_F(Strdiff3test, merge_test20) {
|
||||||
ASSERT_TRUE(merge_cases[20].is_merge_success);
|
ASSERT_TRUE(merge_cases[20].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[20].S, merge_cases[20].merged_seq);
|
ASSERT_EQ(merge_cases[20].S, merge_cases[20].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test21) {
|
TEST_F(Strdiff3test, merge_test21) {
|
||||||
ASSERT_TRUE(merge_cases[21].is_merge_success);
|
ASSERT_TRUE(merge_cases[21].is_merge_success);
|
||||||
ASSERT_EQ( merge_cases[21].S, merge_cases[21].merged_seq);
|
ASSERT_EQ(merge_cases[21].S, merge_cases[21].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test22) {
|
TEST_F(Strdiff3test, merge_test22) {
|
||||||
ASSERT_TRUE(merge_cases[22].is_merge_success);
|
ASSERT_TRUE(merge_cases[22].is_merge_success);
|
||||||
ASSERT_EQ( merge_cases[22].S, merge_cases[22].merged_seq);
|
ASSERT_EQ(merge_cases[22].S, merge_cases[22].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, merge_test23) {
|
TEST_F(Strdiff3test, merge_test23) {
|
||||||
ASSERT_TRUE(merge_cases[23].is_merge_success);
|
ASSERT_TRUE(merge_cases[23].is_merge_success);
|
||||||
ASSERT_EQ(merge_cases[23].S, merge_cases[23].merged_seq);
|
ASSERT_EQ(merge_cases[23].S, merge_cases[23].merged_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, detect_confliction_test0) {
|
TEST_F(Strdiff3test, detect_confliction_test0) {
|
||||||
ASSERT_FALSE(detect_cases[0].is_merge_success);
|
ASSERT_FALSE(detect_cases[0].is_merge_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, detect_confliction_test1) {
|
TEST_F(Strdiff3test, detect_confliction_test1) {
|
||||||
ASSERT_FALSE(detect_cases[1].is_merge_success);
|
ASSERT_FALSE(detect_cases[1].is_merge_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdiff3test, custom_comparator_test0) {
|
TEST_F(Strdiff3test, custom_comparator_test0) {
|
||||||
ASSERT_TRUE(custom_cases[0].is_merge_success);
|
ASSERT_TRUE(custom_cases[0].is_merge_success);
|
||||||
ASSERT_EQ(custom_cases[0].S, custom_cases[0].merged_seq);
|
ASSERT_EQ(custom_cases[0].S, custom_cases[0].merged_seq);
|
||||||
}
|
}
|
||||||
|
@ -1,102 +1,113 @@
|
|||||||
#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) typedef struct case_t {
|
||||||
dtl_test_typedefs(char, string)
|
sequence A;
|
||||||
typedef struct case_t {
|
sequence B;
|
||||||
sequence A;
|
size_t editdis;
|
||||||
sequence B;
|
elemVec lcs_v;
|
||||||
size_t editdis;
|
sequence lcs_s;
|
||||||
elemVec lcs_v;
|
sesElemVec ses_seq;
|
||||||
sequence lcs_s;
|
uniHunkVec hunk_v;
|
||||||
sesElemVec ses_seq;
|
size_t editdis_ses;
|
||||||
uniHunkVec hunk_v;
|
size_t editdis_uni;
|
||||||
size_t editdis_ses;
|
string path_rses;
|
||||||
size_t editdis_uni;
|
string path_rhunks;
|
||||||
string path_rses;
|
} case_t;
|
||||||
string path_rhunks;
|
typedef vector<case_t> caseVec;
|
||||||
} case_t;
|
|
||||||
typedef vector< case_t > caseVec;
|
|
||||||
|
|
||||||
caseVec diff_cases;
|
caseVec diff_cases;
|
||||||
caseVec only_editdis_cases;
|
caseVec only_editdis_cases;
|
||||||
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,
|
||||||
case_t c;
|
bool onlyEditdis = false) {
|
||||||
elemVec lcs_v;
|
case_t c;
|
||||||
string diff_name("strdiff");
|
elemVec lcs_v;
|
||||||
|
string diff_name("strdiff");
|
||||||
|
|
||||||
Diff< elem, sequence, comparator > diff(a, b);
|
Diff<elem, sequence, comparator> diff(a, b);
|
||||||
if (onlyEditdis) {
|
if (onlyEditdis) {
|
||||||
diff.onOnlyEditDistance();
|
diff.onOnlyEditDistance();
|
||||||
}
|
|
||||||
|
|
||||||
diff.compose();
|
|
||||||
diff.composeUnifiedHunks();
|
|
||||||
lcs_v = diff.getLcsVec();
|
|
||||||
|
|
||||||
if (test_name != "") {
|
|
||||||
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);
|
|
||||||
diff_resultset_exist_check(path_lses);
|
|
||||||
diff_resultset_exist_check(path_lhunks);
|
|
||||||
|
|
||||||
create_file< elem, sequence, comparator >(path_rses, diff, TYPE_DIFF_SES);
|
|
||||||
create_file< elem, sequence, comparator >(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();
|
|
||||||
c.lcs_s = sequence(lcs_v.begin(), lcs_v.end());
|
|
||||||
c.ses_seq = diff.getSes().getSequence();
|
|
||||||
c.hunk_v = diff.getUniHunks();
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUp(void) {
|
diff.compose();
|
||||||
diff_cases.push_back(createCase< Compare< elem > >("abc", "abd", "diff_test0"));
|
diff.composeUnifiedHunks();
|
||||||
diff_cases.push_back(createCase< Compare< elem > >("acbdeacbed", "acebdabbabed", "diff_test1"));
|
lcs_v = diff.getLcsVec();
|
||||||
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"));
|
|
||||||
|
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("abc", "abd", "", true));
|
if (test_name != "") {
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("acbdeacbed", "acebdabbabed", "", true));
|
string path_lses = create_path(test_name, diff_name, TYPE_DIFF_SES);
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("abcdef", "dacfea", "", true));
|
string path_rses = create_path(test_name, diff_name, TYPE_DIFF_SES, true);
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("abcbda", "bdcaba", "", true));
|
string path_lhunks = create_path(test_name, diff_name, TYPE_DIFF_UNI);
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("bokko", "bokkko", "", true));
|
string path_rhunks =
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("", "", "", true));
|
create_path(test_name, diff_name, TYPE_DIFF_UNI, true);
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("a", "", "", true));
|
diff_resultset_exist_check(path_lses);
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("", "b", "", true));
|
diff_resultset_exist_check(path_lhunks);
|
||||||
only_editdis_cases.push_back(createCase< Compare< elem > >("acbdeaqqqqqqqcbed", "acebdabbqqqqqqqabed", "", true));
|
|
||||||
|
|
||||||
custom_cases.push_back(createCase< CaseInsensitive >("abc", "Abc", "custom_test0"));
|
create_file<elem, sequence, comparator>(path_rses, diff, TYPE_DIFF_SES);
|
||||||
|
create_file<elem, sequence, comparator>(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown () {
|
c.A = a;
|
||||||
for_each(diff_cases.begin(), diff_cases.end(), Remover< case_t >());
|
c.B = b;
|
||||||
for_each(custom_cases.begin(), custom_cases.end(), Remover< case_t >());
|
c.editdis = diff.getEditDistance();
|
||||||
}
|
c.lcs_s = sequence(lcs_v.begin(), lcs_v.end());
|
||||||
|
c.ses_seq = diff.getSes().getSequence();
|
||||||
|
c.hunk_v = diff.getUniHunks();
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
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>>("", "", "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"));
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
custom_cases.push_back(
|
||||||
|
createCase<CaseInsensitive>("abc", "Abc", "custom_test0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() {
|
||||||
|
for_each(diff_cases.begin(), diff_cases.end(), Remover<case_t>());
|
||||||
|
for_each(custom_cases.begin(), custom_cases.end(), Remover<case_t>());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strdifftest
|
* Strdifftest
|
||||||
* check list is following
|
* check list is following
|
||||||
@ -107,193 +118,193 @@ protected :
|
|||||||
* - onOnlyEditDistance
|
* - onOnlyEditDistance
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TEST_F (Strdifftest, diff_test0) {
|
TEST_F(Strdifftest, diff_test0) {
|
||||||
|
|
||||||
EXPECT_EQ(2, diff_cases[0].editdis);
|
EXPECT_EQ(2, diff_cases[0].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("ab", diff_cases[0].lcs_s);
|
EXPECT_EQ("ab", diff_cases[0].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[0].editdis_ses);
|
ASSERT_EQ(0, diff_cases[0].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[0].editdis_uni);
|
ASSERT_EQ(0, diff_cases[0].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, diff_test1) {
|
TEST_F(Strdifftest, diff_test1) {
|
||||||
EXPECT_EQ(6, diff_cases[1].editdis);
|
EXPECT_EQ(6, diff_cases[1].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("acbdabed", diff_cases[1].lcs_s);
|
EXPECT_EQ("acbdabed", diff_cases[1].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[1].editdis_ses);
|
ASSERT_EQ(0, diff_cases[1].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[1].editdis_uni);
|
ASSERT_EQ(0, diff_cases[1].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, diff_test2) {
|
TEST_F(Strdifftest, diff_test2) {
|
||||||
EXPECT_EQ(6, diff_cases[2].editdis);
|
EXPECT_EQ(6, diff_cases[2].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("acf", diff_cases[2].lcs_s);
|
EXPECT_EQ("acf", diff_cases[2].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[2].editdis_ses);
|
ASSERT_EQ(0, diff_cases[2].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[2].editdis_uni);
|
ASSERT_EQ(0, diff_cases[2].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, diff_test3) {
|
TEST_F(Strdifftest, diff_test3) {
|
||||||
EXPECT_EQ(4, diff_cases[3].editdis);
|
EXPECT_EQ(4, diff_cases[3].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("bcba", diff_cases[3].lcs_s);
|
EXPECT_EQ("bcba", diff_cases[3].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[3].editdis_ses);
|
ASSERT_EQ(0, diff_cases[3].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[3].editdis_uni);
|
ASSERT_EQ(0, diff_cases[3].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, diff_test4) {
|
TEST_F(Strdifftest, diff_test4) {
|
||||||
EXPECT_EQ(1, diff_cases[4].editdis);
|
EXPECT_EQ(1, diff_cases[4].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("bokko", diff_cases[4].lcs_s);
|
EXPECT_EQ("bokko", diff_cases[4].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[4].editdis_ses);
|
ASSERT_EQ(0, diff_cases[4].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[4].editdis_uni);
|
ASSERT_EQ(0, diff_cases[4].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, diff_test5) {
|
TEST_F(Strdifftest, diff_test5) {
|
||||||
EXPECT_EQ(0, diff_cases[5].editdis);
|
EXPECT_EQ(0, diff_cases[5].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", diff_cases[5].lcs_s);
|
EXPECT_EQ("", diff_cases[5].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[5].editdis_ses);
|
ASSERT_EQ(0, diff_cases[5].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[5].editdis_uni);
|
ASSERT_EQ(0, diff_cases[5].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, diff_test6) {
|
TEST_F(Strdifftest, diff_test6) {
|
||||||
EXPECT_EQ(1, diff_cases[6].editdis);
|
EXPECT_EQ(1, diff_cases[6].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", diff_cases[6].lcs_s);
|
EXPECT_EQ("", diff_cases[6].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[6].editdis_ses);
|
ASSERT_EQ(0, diff_cases[6].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[6].editdis_uni);
|
ASSERT_EQ(0, diff_cases[6].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, diff_test7) {
|
TEST_F(Strdifftest, diff_test7) {
|
||||||
EXPECT_EQ(1, diff_cases[7].editdis);
|
EXPECT_EQ(1, diff_cases[7].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", diff_cases[7].lcs_s);
|
EXPECT_EQ("", diff_cases[7].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[7].editdis_ses);
|
ASSERT_EQ(0, diff_cases[7].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[7].editdis_uni);
|
ASSERT_EQ(0, diff_cases[7].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, diff_test8) {
|
TEST_F(Strdifftest, diff_test8) {
|
||||||
EXPECT_EQ(6, diff_cases[8].editdis);
|
EXPECT_EQ(6, diff_cases[8].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("acbdaqqqqqqqbed", diff_cases[8].lcs_s);
|
EXPECT_EQ("acbdaqqqqqqqbed", diff_cases[8].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[8].editdis_ses);
|
ASSERT_EQ(0, diff_cases[8].editdis_ses);
|
||||||
|
|
||||||
ASSERT_EQ(0, diff_cases[8].editdis_uni);
|
ASSERT_EQ(0, diff_cases[8].editdis_uni);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, only_editdis_test0) {
|
TEST_F(Strdifftest, only_editdis_test0) {
|
||||||
EXPECT_EQ(2, only_editdis_cases[0].editdis);
|
EXPECT_EQ(2, only_editdis_cases[0].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", only_editdis_cases[0].lcs_s);
|
EXPECT_EQ("", only_editdis_cases[0].lcs_s);
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[0].ses_seq.empty());
|
ASSERT_TRUE(only_editdis_cases[0].ses_seq.empty());
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[0].hunk_v.empty());
|
ASSERT_TRUE(only_editdis_cases[0].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, only_editdis_test1) {
|
TEST_F(Strdifftest, only_editdis_test1) {
|
||||||
EXPECT_EQ(6, only_editdis_cases[1].editdis);
|
EXPECT_EQ(6, only_editdis_cases[1].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", only_editdis_cases[1].lcs_s);
|
EXPECT_EQ("", only_editdis_cases[1].lcs_s);
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[1].ses_seq.empty());
|
ASSERT_TRUE(only_editdis_cases[1].ses_seq.empty());
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[1].hunk_v.empty());
|
ASSERT_TRUE(only_editdis_cases[1].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, only_editdis_test2) {
|
TEST_F(Strdifftest, only_editdis_test2) {
|
||||||
EXPECT_EQ(6, only_editdis_cases[2].editdis);
|
EXPECT_EQ(6, only_editdis_cases[2].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", only_editdis_cases[2].lcs_s);
|
EXPECT_EQ("", only_editdis_cases[2].lcs_s);
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[2].ses_seq.empty());
|
ASSERT_TRUE(only_editdis_cases[2].ses_seq.empty());
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[2].hunk_v.empty());
|
ASSERT_TRUE(only_editdis_cases[2].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, only_editdis_test3) {
|
TEST_F(Strdifftest, only_editdis_test3) {
|
||||||
EXPECT_EQ(4, only_editdis_cases[3].editdis);
|
EXPECT_EQ(4, only_editdis_cases[3].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", only_editdis_cases[3].lcs_s);
|
EXPECT_EQ("", only_editdis_cases[3].lcs_s);
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[3].ses_seq.empty());
|
ASSERT_TRUE(only_editdis_cases[3].ses_seq.empty());
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[3].hunk_v.empty());
|
ASSERT_TRUE(only_editdis_cases[3].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, only_editdis_test4) {
|
TEST_F(Strdifftest, only_editdis_test4) {
|
||||||
EXPECT_EQ(1, only_editdis_cases[4].editdis);
|
EXPECT_EQ(1, only_editdis_cases[4].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", only_editdis_cases[4].lcs_s);
|
EXPECT_EQ("", only_editdis_cases[4].lcs_s);
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[4].ses_seq.empty());
|
ASSERT_TRUE(only_editdis_cases[4].ses_seq.empty());
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[4].hunk_v.empty());
|
ASSERT_TRUE(only_editdis_cases[4].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, only_editdis_test5) {
|
TEST_F(Strdifftest, only_editdis_test5) {
|
||||||
EXPECT_EQ(0, only_editdis_cases[5].editdis);
|
EXPECT_EQ(0, only_editdis_cases[5].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", only_editdis_cases[5].lcs_s);
|
EXPECT_EQ("", only_editdis_cases[5].lcs_s);
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[5].ses_seq.empty());
|
ASSERT_TRUE(only_editdis_cases[5].ses_seq.empty());
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[5].hunk_v.empty());
|
ASSERT_TRUE(only_editdis_cases[5].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, only_editdis_test6) {
|
TEST_F(Strdifftest, only_editdis_test6) {
|
||||||
EXPECT_EQ(1, only_editdis_cases[6].editdis);
|
EXPECT_EQ(1, only_editdis_cases[6].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", only_editdis_cases[6].lcs_s);
|
EXPECT_EQ("", only_editdis_cases[6].lcs_s);
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[6].ses_seq.empty());
|
ASSERT_TRUE(only_editdis_cases[6].ses_seq.empty());
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[6].hunk_v.empty());
|
ASSERT_TRUE(only_editdis_cases[6].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, only_editdis_test7) {
|
TEST_F(Strdifftest, only_editdis_test7) {
|
||||||
EXPECT_EQ(1, only_editdis_cases[7].editdis);
|
EXPECT_EQ(1, only_editdis_cases[7].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", only_editdis_cases[7].lcs_s);
|
EXPECT_EQ("", only_editdis_cases[7].lcs_s);
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[7].ses_seq.empty());
|
ASSERT_TRUE(only_editdis_cases[7].ses_seq.empty());
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[7].hunk_v.empty());
|
ASSERT_TRUE(only_editdis_cases[7].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, only_editdis_test8) {
|
TEST_F(Strdifftest, only_editdis_test8) {
|
||||||
EXPECT_EQ(6, only_editdis_cases[8].editdis);
|
EXPECT_EQ(6, only_editdis_cases[8].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("", only_editdis_cases[8].lcs_s);
|
EXPECT_EQ("", only_editdis_cases[8].lcs_s);
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[8].ses_seq.empty());
|
ASSERT_TRUE(only_editdis_cases[8].ses_seq.empty());
|
||||||
|
|
||||||
ASSERT_TRUE(only_editdis_cases[8].hunk_v.empty());
|
ASSERT_TRUE(only_editdis_cases[8].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F (Strdifftest, custom_comparator_test0) {
|
TEST_F(Strdifftest, custom_comparator_test0) {
|
||||||
EXPECT_EQ(0, custom_cases[0].editdis);
|
EXPECT_EQ(0, custom_cases[0].editdis);
|
||||||
|
|
||||||
EXPECT_EQ("abc", custom_cases[0].lcs_s);
|
EXPECT_EQ("abc", custom_cases[0].lcs_s);
|
||||||
|
|
||||||
ASSERT_EQ(0, custom_cases[0].editdis_ses);
|
ASSERT_EQ(0, custom_cases[0].editdis_ses);
|
||||||
|
|
||||||
ASSERT_TRUE(custom_cases[0].hunk_v.empty());
|
ASSERT_TRUE(custom_cases[0].hunk_v.empty());
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
#ifndef DTL_COMPARATORS
|
#ifndef DTL_COMPARATORS
|
||||||
#define DTL_COMPARATORS
|
#define DTL_COMPARATORS
|
||||||
|
|
||||||
class CaseInsensitive: public dtl::Compare<char> {
|
class CaseInsensitive : public dtl::Compare<char> {
|
||||||
public:
|
public:
|
||||||
virtual bool impl(const char& a, const char& b) const {
|
virtual bool impl(const char &a, const char &b) const {
|
||||||
return tolower(a) == tolower(b);
|
return tolower(a) == tolower(b);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class StringCaseInsensitive: public dtl::Compare<string> {
|
class StringCaseInsensitive : public dtl::Compare<string> {
|
||||||
public:
|
public:
|
||||||
virtual bool impl(const string& a, const string& b) const {
|
virtual bool impl(const string &a, const string &b) const {
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DTL_COMPARATORS
|
#endif // DTL_COMPARATORS
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
@ -1,56 +1,63 @@
|
|||||||
|
|
||||||
#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,
|
||||||
string ret;
|
bool is_use_suffix) {
|
||||||
switch (t) {
|
string ret;
|
||||||
case TYPE_DIFF_SES:
|
switch (t) {
|
||||||
ret = (getcwd(NULL, 0) + string("/") + string("ses") + string("/") + diff_name + string("/") + test_name);
|
case TYPE_DIFF_SES:
|
||||||
break;
|
ret = (getcwd(NULL, 0) + string("/") + string("ses") + string("/") +
|
||||||
case TYPE_DIFF_UNI:
|
diff_name + string("/") + test_name);
|
||||||
ret = (getcwd(NULL, 0) + string("/") + string("hunks") + string("/") + diff_name + string("/") + test_name);
|
break;
|
||||||
break;
|
case TYPE_DIFF_UNI:
|
||||||
}
|
ret = (getcwd(NULL, 0) + string("/") + string("hunks") + string("/") +
|
||||||
ret += is_use_suffix ? "_" : "";
|
diff_name + string("/") + test_name);
|
||||||
return ret;
|
break;
|
||||||
|
}
|
||||||
|
ret += is_use_suffix ? "_" : "";
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
string buf;
|
string buf;
|
||||||
ifstream lifs(path_l.c_str());
|
ifstream lifs(path_l.c_str());
|
||||||
ifstream rifs(path_r.c_str());
|
ifstream rifs(path_r.c_str());
|
||||||
|
|
||||||
vector< string > llines;
|
vector<string> llines;
|
||||||
vector< string > rlines;
|
vector<string> rlines;
|
||||||
|
|
||||||
while (getline(lifs, buf)) {
|
while (getline(lifs, buf)) {
|
||||||
llines.push_back(buf);
|
llines.push_back(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (getline(rifs, buf)) {
|
while (getline(rifs, buf)) {
|
||||||
rlines.push_back(buf);
|
rlines.push_back(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
Diff< string, vector< string > > diff_uni(llines, rlines);
|
Diff<string, vector<string>> diff_uni(llines, rlines);
|
||||||
diff_uni.compose();
|
diff_uni.compose();
|
||||||
return diff_uni.getEditDistance();
|
return diff_uni.getEditDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_file_exist (string& fs) {
|
bool is_file_exist(string &fs) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if ((fp = fopen(fs.c_str(), "r")) == NULL) {
|
if ((fp = fopen(fs.c_str(), "r")) == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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!!!===="
|
||||||
cerr << "diff result set:" << fs << " is not found." << endl;
|
"=================================================="
|
||||||
cerr << "======================================================Error!!!======================================================" << endl;
|
<< endl;
|
||||||
cerr << "excute dtl_test in dtl/test!" << endl;
|
cerr << "diff result set:" << fs << " is not found." << endl;
|
||||||
exit(EXIT_FAILURE);
|
cerr << "======================================================Error!!!===="
|
||||||
}
|
"=================================================="
|
||||||
|
<< endl;
|
||||||
|
cerr << "excute dtl_test in dtl/test!" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,69 +2,70 @@
|
|||||||
#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) \
|
||||||
typedef e_type elem; \
|
typedef e_type elem; \
|
||||||
typedef seq_type sequence; \
|
typedef seq_type sequence; \
|
||||||
typedef pair< elem, elemInfo > sesElem; \
|
typedef pair<elem, elemInfo> sesElem; \
|
||||||
typedef vector< elem > elemVec; \
|
typedef vector<elem> elemVec; \
|
||||||
typedef vector< sesElem > sesElemVec; \
|
typedef vector<sesElem> sesElemVec; \
|
||||||
typedef vector< uniHunk< sesElem > > uniHunkVec;
|
typedef vector<uniHunk<sesElem>> uniHunkVec;
|
||||||
|
|
||||||
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,
|
||||||
size_t cal_diff_uni (const string& path_l, const string& path_r);
|
bool is_use_suffix = false);
|
||||||
bool is_file_exist (string& fs);
|
size_t cal_diff_uni(const string &path_l, const string &path_r);
|
||||||
void diff_resultset_exist_check (string &fs);
|
bool is_file_exist(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());
|
remove(v.path_rhunks.c_str());
|
||||||
remove(v.path_rhunks.c_str());
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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,
|
||||||
ofstream ofs;
|
enum type_diff t) {
|
||||||
ofs.open(path.c_str());
|
ofstream ofs;
|
||||||
switch (t) {
|
ofs.open(path.c_str());
|
||||||
case TYPE_DIFF_SES:
|
switch (t) {
|
||||||
diff.printSES(ofs);
|
case TYPE_DIFF_SES:
|
||||||
break;
|
diff.printSES(ofs);
|
||||||
case TYPE_DIFF_UNI:
|
break;
|
||||||
diff.printUnifiedFormat(ofs);
|
case TYPE_DIFF_UNI:
|
||||||
break;
|
diff.printUnifiedFormat(ofs);
|
||||||
}
|
break;
|
||||||
ofs.close();
|
}
|
||||||
|
ofs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DTL_TEST_COMMON
|
#endif // DTL_TEST_COMMON
|
||||||
|
Loading…
x
Reference in New Issue
Block a user