DIFFOPTIONS diffOptions = {0};
m_diffWrapper.GetOptions(&diffOptions);
- std::vector<strdiff::wdiff> worddiffs;
// Make the call to stringdiffs, which does all the hard & tedious computations
- strdiff::ComputeWordDiffs(m_nBuffers, str,
+ std::vector<strdiff::wdiff> worddiffs = strdiff::ComputeWordDiffs(m_nBuffers, str,
!diffOptions.bIgnoreCase,
diffOptions.nIgnoreWhitespace,
GetBreakType(), // whitespace only or include punctuation
- GetByteColoringOption(),
- &worddiffs);
+ GetByteColoringOption());
if (!worddiffs.empty())
{
for (int file = 0; file < m_nBuffers; ++file)
}
bool CMergeDoc::WordListCopy(int srcPane, int dstPane, int nDiff, int firstWordDiff, int lastWordDiff,
- std::vector<int> *pWordDiffIndice, bool bGroupWithPrevious /*= false*/, bool bUpdateView /*= true*/)
+ const std::vector<int> *pWordDiffIndice, bool bGroupWithPrevious /*= false*/, bool bUpdateView /*= true*/)
{
int nGroup = GetActiveMergeView()->m_nThisGroup;
CMergeEditView *pViewSrc = m_pView[nGroup][srcPane];
return false; // abort copying
}
- std::vector<WordDiff> worddiffs;
- GetWordDiffArray(cd_dbegin, &worddiffs);
+ std::vector<WordDiff> worddiffs = GetWordDiffArray(cd_dbegin);
if (worddiffs.empty())
return false;
void CopyMultipleList(int srcPane, int dstPane, int firstDiff, int lastDiff, int firstWordDiff = -1, int lastWordDiff = -1);
void DoAutoMerge(int dstPane);
bool SanityCheckDiff(DIFFRANGE dr) const;
- bool WordListCopy(int srcPane, int dstPane, int nDiff, int nFirstWordDiff, int nLastWordDiff, std::vector<int> *pWordDiffIndice, bool bGroupWithPrevious = false, bool bUpdateView = true);
+ bool WordListCopy(int srcPane, int dstPane, int nDiff, int nFirstWordDiff, int nLastWordDiff, const std::vector<int> *pWordDiffIndice, bool bGroupWithPrevious = false, bool bUpdateView = true);
bool ListCopy(int srcPane, int dstPane, int nDiff = -1, bool bGroupWithPrevious = false, bool bUpdateView = true);
bool TrySaveAs(String& strPath, int &nLastErrorCode, String & sError,
int nBuffer, PackingInfo * pInfoTempUnpacker);
public:
typedef enum { BYTEDIFF, WORDDIFF } DIFFLEVEL;
void Showlinediff(CMergeEditView *pView, bool bReversed = false);
- void GetWordDiffArray(int nLineIndex, std::vector<WordDiff> *pWordDiffs);
+ std::vector<WordDiff> GetWordDiffArray(int nLineIndex);
void ClearWordDiffCache(int nDiff = -1);
private:
void Computelinediff(CMergeEditView *pView, CRect rc[], bool bReversed);
int breakType = GetBreakType(); // whitespace only or include punctuation
bool byteColoring = GetByteColoringOption();
- std::vector<strdiff::wdiff> worddiffs;
- strdiff::ComputeWordDiffs(2, str, casitive, xwhite, breakType, byteColoring, &worddiffs);
+ std::vector<strdiff::wdiff> worddiffs = strdiff::ComputeWordDiffs(2, str, casitive, xwhite, breakType, byteColoring);
int nDiffLenSum = 0;
for (std::vector<strdiff::wdiff>::const_iterator it = worddiffs.begin(); it != worddiffs.end(); ++it)
CPoint ptStart, ptEnd;
pView->GetSelection(ptStart, ptEnd);
- vector<WordDiff> worddiffs;
- GetWordDiffArray(ptStart.y, &worddiffs);
+ vector<WordDiff> worddiffs = GetWordDiffArray(ptStart.y);
if (worddiffs.empty())
return;
* This is used by algorithm for line diff coloring
* (Line diff coloring is distinct from the selection highlight code)
*/
-void CMergeDoc::GetWordDiffArray(int nLineIndex, vector<WordDiff> *pWordDiffs)
+std::vector<WordDiff> CMergeDoc::GetWordDiffArray(int nLineIndex)
{
int file;
DIFFRANGE cd;
+ std::vector<WordDiff> worddiffs;
for (file = 0; file < m_nBuffers; file++)
{
if (nLineIndex >= m_ptBuf[file]->GetLineCount())
- return;
+ return worddiffs;
}
int nDiff = m_diffList.LineToDiff(nLineIndex);
if (nDiff == -1)
- return;
+ return worddiffs;
std::map<int, std::vector<WordDiff> >::iterator itmap = m_cacheWordDiffs.find(nDiff);
if (itmap != m_cacheWordDiffs.end())
{
- pWordDiffs->resize((*itmap).second.size());
- std::copy((*itmap).second.begin(), (*itmap).second.end(), pWordDiffs->begin());
- return;
+ worddiffs.resize((*itmap).second.size());
+ std::copy((*itmap).second.begin(), (*itmap).second.end(), worddiffs.begin());
+ return worddiffs;
}
m_diffList.GetDiff(nDiff, cd);
for (file = 0; file < m_nBuffers; file++)
{
if (nLineEnd >= m_ptBuf[file]->GetLineCount())
- return;
+ return worddiffs;
nOffsets[file].reset(new int[nLineEnd - nLineBegin + 1]);
CString strText;
if (nLineBegin != nLineEnd || m_ptBuf[file]->GetLineLength(nLineEnd) > 0)
int breakType = GetBreakType(); // whitespace only or include punctuation
bool byteColoring = GetByteColoringOption();
- std::vector<strdiff::wdiff> worddiffs;
// Make the call to stringdiffs, which does all the hard & tedious computations
- strdiff::ComputeWordDiffs(m_nBuffers, str, casitive, xwhite, breakType, byteColoring, &worddiffs);
+ std::vector<strdiff::wdiff> wdiffs = strdiff::ComputeWordDiffs(m_nBuffers, str, casitive, xwhite, breakType, byteColoring);
int i;
std::vector<strdiff::wdiff>::iterator it;
- for (i = 0, it = worddiffs.begin(); it != worddiffs.end(); ++i, ++it)
+ for (i = 0, it = wdiffs.begin(); it != wdiffs.end(); ++i, ++it)
{
WordDiff wd;
for (file = 0; file < m_nBuffers; file++)
}
wd.op = it->op;
- pWordDiffs->push_back(wd);
+ worddiffs.push_back(wd);
}
if (!diffPerLine)
{
- m_cacheWordDiffs[nDiff].resize(pWordDiffs->size());
- std::copy(pWordDiffs->begin(), pWordDiffs->end(), m_cacheWordDiffs[nDiff].begin());
+ m_cacheWordDiffs[nDiff].resize(worddiffs.size());
+ std::copy(worddiffs.begin(), worddiffs.end(), m_cacheWordDiffs[nDiff].begin());
}
- return;
+ return worddiffs;
}
if (firstDiff != -1 && lastDiff != -1)
{
DIFFRANGE di;
- vector<WordDiff> worddiffs;
if (ptStart != ptEnd)
{
if (firstWordDiff == -1)
{
VERIFY(pd->m_diffList.GetDiff(firstDiff, di));
- pd->GetWordDiffArray(firstLine, &worddiffs);
+ vector<WordDiff> worddiffs = pd->GetWordDiffArray(firstLine);
for (size_t i = 0; i < worddiffs.size(); ++i)
{
if (worddiffs[i].endline[m_nThisPane] > firstLine ||
}
VERIFY(pd->m_diffList.GetDiff(lastDiff, di));
- pd->GetWordDiffArray(lastLine, &worddiffs);
+ vector<WordDiff> worddiffs = pd->GetWordDiffArray(lastLine);
for (size_t i = worddiffs.size() - 1; i != (size_t)-1; --i)
{
if (worddiffs[i].beginline[m_nThisPane] < lastLine ||
if (pDoc->IsEditedAfterRescan(m_nThisPane))
return emptyBlocks;
- vector<WordDiff> worddiffs;
int nDiff = pDoc->m_diffList.LineToDiff(nLineIndex);
if (nDiff == -1)
return emptyBlocks;
if (unemptyLineCount < 2)
return emptyBlocks;
- pDoc->GetWordDiffArray(nLineIndex, &worddiffs);
+ vector<WordDiff> worddiffs = pDoc->GetWordDiffArray(nLineIndex);
size_t nWordDiffs = worddiffs.size();
bool lineInCurrentDiff = IsLineInCurrentDiff(nLineIndex);
BreakChars = _tcsdup(breakChars);
}
-void
+std::vector<wdiff>
ComputeWordDiffs(const String& str1, const String& str2,
- bool case_sensitive, int whitespace, int breakType, bool byte_level,
- std::vector<wdiff> * pDiffs)
+ bool case_sensitive, int whitespace, int breakType, bool byte_level)
{
String strs[3] = {str1, str2, _T("")};
- ComputeWordDiffs(2, strs, case_sensitive, whitespace, breakType, byte_level, pDiffs);
+ return ComputeWordDiffs(2, strs, case_sensitive, whitespace, breakType, byte_level);
}
struct Comp02Functor
/**
* @brief Construct our worker object and tell it to do the work
*/
-void
+std::vector<wdiff>
ComputeWordDiffs(int nFiles, const String str[3],
- bool case_sensitive, int whitespace, int breakType, bool byte_level,
- std::vector<wdiff> * pDiffs)
+ bool case_sensitive, int whitespace, int breakType, bool byte_level)
{
+ std::vector<wdiff> diffs;
if (nFiles == 2)
{
- stringdiffs sdiffs(str[0], str[1], case_sensitive, whitespace, breakType, pDiffs);
+ stringdiffs sdiffs(str[0], str[1], case_sensitive, whitespace, breakType, &diffs);
// Hash all words in both lines and then compare them word by word
// storing differences into m_wdiffs
sdiffs.BuildWordDiffList();
{
if (str[0].empty())
{
- stringdiffs sdiffs(str[1], str[2], case_sensitive, whitespace, breakType, pDiffs);
+ stringdiffs sdiffs(str[1], str[2], case_sensitive, whitespace, breakType, &diffs);
sdiffs.BuildWordDiffList();
if (byte_level)
sdiffs.wordLevelToByteLevel();
sdiffs.PopulateDiffs();
- for (size_t i = 0; i < pDiffs->size(); i++)
+ for (size_t i = 0; i < diffs.size(); i++)
{
- wdiff& diff = (*pDiffs)[i];
+ wdiff& diff = diffs[i];
diff.begin[2] = diff.begin[1];
diff.begin[1] = diff.begin[0];
diff.begin[0] = 0;
}
else if (str[1].empty())
{
- stringdiffs sdiffs(str[0], str[2], case_sensitive, whitespace, breakType, pDiffs);
+ stringdiffs sdiffs(str[0], str[2], case_sensitive, whitespace, breakType, &diffs);
sdiffs.BuildWordDiffList();
if (byte_level)
sdiffs.wordLevelToByteLevel();
sdiffs.PopulateDiffs();
- for (size_t i = 0; i < pDiffs->size(); i++)
+ for (size_t i = 0; i < diffs.size(); i++)
{
- wdiff& diff = (*pDiffs)[i];
+ wdiff& diff = diffs[i];
diff.begin[2] = diff.begin[1];
//diff.begin[0] = diff.begin[0];
diff.begin[1] = 0;
}
else if (str[2].empty())
{
- stringdiffs sdiffs(str[0], str[1], case_sensitive, whitespace, breakType, pDiffs);
+ stringdiffs sdiffs(str[0], str[1], case_sensitive, whitespace, breakType, &diffs);
sdiffs.BuildWordDiffList();
if (byte_level)
sdiffs.wordLevelToByteLevel();
sdiffs.PopulateDiffs();
- for (size_t i = 0; i < pDiffs->size(); i++)
+ for (size_t i = 0; i < diffs.size(); i++)
{
- wdiff& diff = (*pDiffs)[i];
+ wdiff& diff = diffs[i];
//diff.begin[1] = diff.begin[1];
//diff.begin[0] = diff.begin[0];
diff.begin[2] = 0;
sdiffs10.PopulateDiffs();
sdiffs12.PopulateDiffs();
- Make3wayDiff(*pDiffs, diffs10, diffs12,
+ Make3wayDiff(diffs, diffs10, diffs12,
Comp02Functor(str, case_sensitive), false);
}
}
+ return diffs;
}
/**
void
stringdiffs::BuildWordDiffList()
{
- BuildWordsArray(m_str1, m_words1);
- BuildWordsArray(m_str2, m_words2);
+ m_words1 = BuildWordsArray(m_str1);
+ m_words2 = BuildWordsArray(m_str2);
#ifdef _WIN64
if (m_words1.size() > 20480 || m_words2.size() > 20480)
/**
* @brief Break line into constituent words
*/
-void
-stringdiffs::BuildWordsArray(const String & str, std::vector<word>& words)
+std::vector<stringdiffs::word>
+stringdiffs::BuildWordsArray(const String & str)
{
+ std::vector<word> words;
int i=0, begin=0;
size_t sLen = str.length();
words.push_back(word(begin, e, dlspace, Hash(str, begin, e, 0)));
}
if (i == iLen)
- return;
+ return words;
begin = i;
goto inword;
}
if (i == iLen)
{
- return;
+ return words;
}
else if (atspace)
{
void SetBreakChars(const TCHAR *breakChars);
-void ComputeWordDiffs(const String& str1, const String& str2,
- bool case_sensitive, int whitespace, int breakType, bool byte_level,
- std::vector<wdiff> * pDiffs);
-void ComputeWordDiffs(int nStrings, const String str[3],
- bool case_sensitive, int whitespace, int breakType, bool byte_level,
- std::vector<wdiff> * pDiffs);
+std::vector<wdiff> ComputeWordDiffs(const String& str1, const String& str2,
+ bool case_sensitive, int whitespace, int breakType, bool byte_level);
+std::vector<wdiff> ComputeWordDiffs(int nStrings, const String str[3],
+ bool case_sensitive, int whitespace, int breakType, bool byte_level);
void ComputeByteDiff(const String& str1, const String& str2,
bool casitive, int xwhite,
// Implementation methods
private:
- void BuildWordsArray(const String & str, std::vector<word>& words);
+ std::vector<word> BuildWordsArray(const String & str);
unsigned Hash(const String & str, int begin, int end, unsigned h ) const;
bool AreWordsSame(const word & word1, const word & word2) const;
bool IsWord(const word & word1) const;
// Both strings empty
TEST_F(StringDiffsTest, EmptyBoth)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T(""), _T(""), false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T(""), _T(""), false, 0, 0, false);
EXPECT_EQ(0, diffs.size());
}
// First string empty
TEST_F(StringDiffsTest, EmptyFirst)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T(""), _T("abcde"), false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T(""), _T("abcde"), false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
}
// Second string empty
TEST_F(StringDiffsTest, EmptySecond)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde"), _T(""), false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde"), _T(""), false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, no case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, Default1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde"), _T("abcde"), false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde"), _T("abcde"), false, 0, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, DefaultDiffererentLen)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcdef"), _T("abcde"), false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcdef"), _T("abcde"), false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, no case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, DefaultWhitespaceEnd)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde "), _T("abcde"), false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde "), _T("abcde"), false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, Caseignore1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde"), _T("abcde"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde"), _T("abcde"), true, 0, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, CaseignoreCase1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcde"), _T("abcde"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcde"), _T("abcde"), true, 0, 0, false);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcde "), _T("abcde"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcde "), _T("abcde"), true, 0, 0, false);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcde"), _T(" abcde"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcde"), _T(" abcde"), true, 0, 0, false);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, no case sensitivity, ignore whitespace change, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace3)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde abcde"), _T("abcde abcde"), false, 1, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde abcde"), _T("abcde abcde"), false, 1, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore whitespace change, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace4)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T(" abcde abcde"), _T(" abcde abcde"), false, 1, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T(" abcde abcde"), _T(" abcde abcde"), false, 1, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore whitespace change, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace5)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T(" abcde abcde"), _T(" abcde abcde"), false, 1, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T(" abcde abcde"), _T(" abcde abcde"), false, 1, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Whitespace at begin of first string is a difference
TEST_F(StringDiffsTest, IgnoreWhitespace6)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T(" abcde abcde"), _T("abcde abcde"), false, 1, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T(" abcde abcde"), _T("abcde abcde"), false, 1, 0, false);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, no case sensitivity, ignore whitespace change, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace7)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde abcde"), _T("abcde abcde"), false, 1, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde abcde"), _T("abcde abcde"), false, 1, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde"), _T("abcde"), true, 2, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde"), _T("abcde"), true, 2, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T(" abcde"), _T("abcde"), true, 2, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T(" abcde"), _T("abcde"), true, 2, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace3)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T(" abcde"), _T("abcde"), true, 2, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T(" abcde"), _T("abcde"), true, 2, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace4)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T(" abcde"), _T(" abcde"), true, 2, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T(" abcde"), _T(" abcde"), true, 2, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace5)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde abcde"), _T("abcdeabcde"), true, 2, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde abcde"), _T("abcdeabcde"), true, 2, 0, false);
/// FIXME:
// EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace6)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde abcde"), _T("abcde abcde"), true, 2, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde abcde"), _T("abcde abcde"), true, 2, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace7)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde\tabcde"), _T("abcde abcde"), true, 2, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde\tabcde"), _T("abcde abcde"), true, 2, 0, false);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, WordBreak2Words1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcde fghij"), _T("abcde fghij"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcde fghij"), _T("abcde fghij"), true, 0, 0, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// Last word is different
TEST_F(StringDiffsTest, WordBreak2Words2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde fghij"), _T("abcde fGhij"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde fghij"), _T("abcde fGhij"), true, 0, 0, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// Both words are different
TEST_F(StringDiffsTest, WordBreak2Words3)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde fghij"), _T("ABcde fGhij"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde fghij"), _T("ABcde fGhij"), true, 0, 0, false);
EXPECT_EQ(2, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
// Middle word is different
TEST_F(StringDiffsTest, WordBreak3Words1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde fgHIj klmno"), _T("abcde fghij klmno"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde fgHIj klmno"), _T("abcde fghij klmno"), true, 0, 0, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// Middle word is different
TEST_F(StringDiffsTest, WordBreak3Words2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde fghij klmno"), _T("abcde fGHij klmno"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde fghij klmno"), _T("abcde fGHij klmno"), true, 0, 0, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// First two words are different
TEST_F(StringDiffsTest, WordBreak3Words3)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcDE fGHij klmno"), _T("abcde fghij klmno"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcDE fGHij klmno"), _T("abcde fghij klmno"), true, 0, 0, false);
EXPECT_EQ(2, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
// First two words are different
TEST_F(StringDiffsTest, WordBreak3Words4)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde fghij klmno"), _T("abcDE fGHij klmno"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde fghij klmno"), _T("abcDE fGHij klmno"), true, 0, 0, false);
EXPECT_EQ(2, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
// First and last words are different generating two diffs
TEST_F(StringDiffsTest, WordBreak3Words5)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde fghij KLmno"), _T("abcDE fghij klmno"), true, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde fghij KLmno"), _T("abcDE fghij klmno"), true, 0, 0, false);
EXPECT_EQ(2, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 2)
// First word is different
TEST_F(StringDiffsTest, PunctBreak2Words1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde,fghij"), _T("ABcde,fghij"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde,fghij"), _T("ABcde,fghij"), true, 0, 1, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// First word is different
TEST_F(StringDiffsTest, PunctBreak2Words2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// Both words are different
TEST_F(StringDiffsTest, PunctBreak2Words3)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fGHij"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fGHij"), true, 0, 1, false);
EXPECT_EQ(2, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 2)
// First word is different
TEST_F(StringDiffsTest, PunctBreak3Words1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("Abcde,fghij,klmno"), _T("abcde,fghij,klmno"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde,fghij,klmno"), _T("abcde,fghij,klmno"), true, 0, 1, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// First word is different
TEST_F(StringDiffsTest, PunctBreak3Words2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("Abcde,fghij,klmno"), _T("abcde,fGHij,klmno"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde,fghij,klmno"), _T("abcde,fGHij,klmno"), true, 0, 1, false);
EXPECT_EQ(2, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
// All three words are different
TEST_F(StringDiffsTest, PunctBreak3Words3)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("Abcde,fghij,klmno"), _T("abcde,fGHij,klmNO"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde,fghij,klmno"), _T("abcde,fGHij,klmNO"), true, 0, 1, false);
EXPECT_EQ(3, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
// First word is different
TEST_F(StringDiffsTest, PunctBreak3Words4)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("Abcde,fghij,klmno"), _T("abcde,fghij,klmNO"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde,fghij,klmno"), _T("abcde,fghij,klmNO"), true, 0, 1, false);
EXPECT_EQ(2, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
// Match whole strings
TEST_F(StringDiffsTest, CustomPunct1)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(""));
- strdiff::ComputeWordDiffs(_T("Abcde:fghij"), _T("abcde:fghij"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde:fghij"), _T("abcde:fghij"), true, 0, 1, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// Match whole strings
TEST_F(StringDiffsTest, CustomPunct2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::SetBreakChars(_T(""));
- strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false, &diffs);
+ strdiff::SetBreakChars(_T(""));
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// First word is different
TEST_F(StringDiffsTest, CustomPunctBreak1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::SetBreakChars(_T(":"));
- strdiff::ComputeWordDiffs(_T("Abcde:fghij"), _T("abcde:fghij"), true, 0, 1, false, &diffs);
+ strdiff::SetBreakChars(_T(":"));
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde:fghij"), _T("abcde:fghij"), true, 0, 1, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// First word is different
TEST_F(StringDiffsTest, CustomPunctBreak2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::SetBreakChars(_T(";"));
- strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false, &diffs);
+ strdiff::SetBreakChars(_T(";"));
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// Identical strings, case sensitivity, no whitespace, words, byte-level
TEST_F(StringDiffsTest, ByteLevel1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcde"), _T("abcde"), true, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcde"), _T("abcde"), true, 0, 0, true);
EXPECT_TRUE(diffs.size() == 0);
}
// Identical strings, case sensitivity, no whitespace, words, byte-level
TEST_F(StringDiffsTest, ByteLevel2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcde"), _T("abcde"), true, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcde"), _T("abcde"), true, 0, 0, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// Identical strings, case sensitivity, no whitespace, words, byte-level
TEST_F(StringDiffsTest, ByteLevel3)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBCde"), _T("abcde"), true, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBCde"), _T("abcde"), true, 0, 0, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// Identical strings, case sensitivity, no whitespace, words, byte-level
TEST_F(StringDiffsTest, ByteLevel4)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcde"), _T("abCde"), true, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcde"), _T("abCde"), true, 0, 0, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// NOTE NOTE: This is questionable?
TEST_F(StringDiffsTest, ByteLevel5)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcDe"), _T("abcde"), true, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcDe"), _T("abcde"), true, 0, 0, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// NOTE NOTE: This is questionable?
TEST_F(StringDiffsTest, ByteLevel6)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcde"), _T("abcDe"), true, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcde"), _T("abcDe"), true, 0, 0, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
// NOTE NOTE: This is questionable?
TEST_F(StringDiffsTest, ByteLevel7)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcdE"), _T("abcde"), true, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcdE"), _T("abcde"), true, 0, 0, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff;
if (diffs.size() == 1 )
// NOTE NOTE: This is questionable?
TEST_F(StringDiffsTest, ByteLevel8)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("aBcde"), _T("abcdE"), true, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("aBcde"), _T("abcdE"), true, 0, 0, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff;
if (diffs.size() == 1)
// Char added to begin
TEST_F(StringDiffsAddsTest, AddBeginFirst1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("1abcdefgh"),
- false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("1abcdefgh"),
+ false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
// Char added to begin
TEST_F(StringDiffsAddsTest, AddBeginFirst2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("1abcdefgh"), _T("abcdefgh"),
- false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("1abcdefgh"), _T("abcdefgh"),
+ false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
// Char added to begin
TEST_F(StringDiffsAddsTest, AddBeginFirstChar1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("1abcdefgh"),
- false, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("1abcdefgh"),
+ false, 0, 0, true);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
// Char added to begin
TEST_F(StringDiffsAddsTest, AddBeginFirstChar2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("1abcdefgh"), _T("abcdefgh"),
- false, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("1abcdefgh"), _T("abcdefgh"),
+ false, 0, 0, true);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
// Char added to end
TEST_F(StringDiffsAddsTest, AddEndFirst1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("abcdefgh1"),
- false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("abcdefgh1"),
+ false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
// Char added to end
TEST_F(StringDiffsAddsTest, AddEndFirst2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcdefgh1"), _T("abcdefgh"),
- false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcdefgh1"), _T("abcdefgh"),
+ false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
// Char added to end
TEST_F(StringDiffsAddsTest, AddEndFirstChar1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("abcdefgh1"),
- false, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("abcdefgh1"),
+ false, 0, 0, true);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
// Char added to end
TEST_F(StringDiffsAddsTest, AddEndFirstChar2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(_T("abcdefgh1"), _T("abcdefgh"),
- false, 0, 0, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcdefgh1"), _T("abcdefgh"),
+ false, 0, 0, true);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
// exchange string left right side only
TEST_F(StringDiffsAddsTest, ExchangeString1a)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- strdiff::ComputeWordDiffs(_T("N2130 _RobOk=_INT B_AND 512 ;Roboter bereit"),
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("N2130 _RobOk=_INT B_AND 512 ;Roboter bereit"),
_T("N2040 _RobOk=_INT B_AND 'B1000000000' ;Roboter bereit"),
- false, 1, 0, true, &diffs);
+ false, 1, 0, true);
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
// exchange string left right side only
TEST_F(StringDiffsAddsTest, ExchangeString1b)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- strdiff::ComputeWordDiffs(_T("N2040 _RobOk=_INT B_AND 'B1000000000' ;Roboter bereit"),
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("N2040 _RobOk=_INT B_AND 'B1000000000' ;Roboter bereit"),
_T("N2130 _RobOk=_INT B_AND 512 ;Roboter bereit"),
- false, 1, 0, true, &diffs);
+ false, 1, 0, true);
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
// exchange string left right side only
TEST_F(StringDiffsAddsTest, ExchangeString2a)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789
_T("N1960 IF(R2941==2) OR (R2941==203))"),
_T("N1830 IF((R2941==2) OR (R2941==3) "),
- false, 1, 1, true, &diffs);
+ false, 1, 1, true);
EXPECT_EQ(4, diffs.size());
if (diffs.size() > 3)
{
// exchange string left right side only
TEST_F(StringDiffsAddsTest, ExchangeString2b)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789
_T("N1830 IF((R2941==2) OR (R2941==3) "),
_T("N1960 IF(R2941==2) OR (R2941==203))"),
- false, 1, 1, true, &diffs);
+ false, 1, 1, true);
EXPECT_EQ(4, diffs.size());
if (diffs.size() > 3)
{
// new option third run
TEST_F(StringDiffsAddsTest, RunThird)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789
_T("(sizeof *new);"),
_T("sizeof(*newob));"),
- false, 1, 0, true, &diffs);
+ false, 1, 0, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff;
if (diffs.size() == 1)
// (ENUMRESLANGPROC) added to middle
TEST_F(StringDiffsBugsTest, Bug_1685466_1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
_T("if (EnumResourceLanguages(hinstLang, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO), (ENUMRESLANGPROC)FindNextResLang, (LPARAM)&wLangID) == 0)"),
_T("if (EnumResourceLanguages(hinstLang, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO), FindNextResLang, (LPARAM)&wLangID) == 0)"),
- false, 0, 1, true, &diffs);
+ false, 0, 1, true);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// (ENUMRESLANGPROC) added to middle
TEST_F(StringDiffsBugsTest, Bug_1685466_2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
_T("if (EnumResourceLanguages(hinstLang, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO), (ENUMRESLANGPROC)FindNextResLang, (LPARAM)&wLangID) == 0)"),
_T("if (EnumResourceLanguages(hinstLang, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO), FindNextResLang, (LPARAM)&wLangID) == 0)"),
- false, 0, 1, false, &diffs);
+ false, 0, 1, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// various changes
TEST_F(StringDiffsBugsTest, Bug_1939279_1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
_T("[overlay_oid_origin, overlay_oid_target], [nil, nil]"),
_T("[overlay_oid_origin, overlay_oid_target, origin_file_name, target_file_name], [nil, nil, \"origin.txt\"), \"target.txt\"]"),
- false, 0, 1, true, &diffs);
+ false, 0, 1, true);
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 0)
{
// various changes
TEST_F(StringDiffsBugsTest, Bug_1939279_2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
_T("[overlay_oid_origin, overlay_oid_target], [nil, nil]"),
_T("[overlay_oid_origin, overlay_oid_target, origin_file_name, target_file_name], [nil, nil, \"origin.txt\"), \"target.txt\"]"),
- false, 0, 1, false, &diffs);
+ false, 0, 1, false);
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 0)
{
// Chars added to end
TEST_F(StringDiffsBugsTest, Bug_2022935)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 012345678901234567890
_T("N42=Import"),
_T("N42=Importuj"),
- false, 0, 1, true, &diffs);
+ false, 0, 1, true);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// Char added to end
TEST_F(StringDiffsBugsTest, Bug_2638045)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("LIB_PHP4_DIR=$(RPM_NAME)-$(RPM_VER)/usr/lib/php"),
_T("LIB_PHP4_DIR=$(RPM_NAME)-$(RPM_VER)/usr/lib/php4"),
- false, 0, 0, false, &diffs);
+ false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// Char added to end
TEST_F(StringDiffsBugsTest, Bug_2638045_2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("LIB_PHP4_DIR=$(RPM_NAME)-$(RPM_VER)/usr/lib/php"),
_T("LIB_PHP4_DIR=$(RPM_NAME)-$(RPM_VER)/usr/lib/php4"),
- false, 0, 1, false, &diffs);
+ false, 0, 1, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// Char added to end
TEST_F(StringDiffsBugsTest, Bug_2638045_3)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("LIB_PHP4_DIR=$(RPM_NAME)-$(RPM_VER)/usr/lib/php"),
_T("LIB_PHP4_DIR=$(RPM_NAME)-$(RPM_VER)/usr/lib/php4"),
- false, 0, 0, true, &diffs);
+ false, 0, 0, true);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// Char added to end
TEST_F(StringDiffsBugsTest, Bug_2638045_4)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T("/"));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("LIB_PHP4_DIR=$(RPM_NAME)-$(RPM_VER)/usr/lib/php"),
_T("LIB_PHP4_DIR=$(RPM_NAME)-$(RPM_VER)/usr/lib/php4"),
- false, 0, 1, false, &diffs);
+ false, 0, 1, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2779834_1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("if (nDiff < m_diffs.size())"),
_T("if(nDiff < (int) m_diffs.size())"),
- false, 0, 0, false, &diffs);
+ false, 0, 0, false);
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 0)
{
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2779834_2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("if (nDiff < m_diffs.size())"),
_T("if(nDiff < (int) m_diffs.size())"),
- false, 0, 0, true, &diffs);
+ false, 0, 0, true);
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 0)
{
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2783185_1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("const string ManualFolder = \"Manual\";"),
_T("private const string ManualFolder = \"Manual\";"),
- false, 0, 0, true, &diffs);
+ false, 0, 0, true);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2783185_2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("const string ManualFolder = \"Manual\";"),
_T("private const string ManualFolder = \"Manual\";"),
- false, 0, 0, false, &diffs);
+ false, 0, 0, false);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2791879_1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abc def ghi jkl mno"),
_T("abc defx ghi jklx mno"),
- false, 0, 0, true, &diffs);
+ false, 0, 0, true);
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2791879_2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abc def ghi jkl mno"),
_T("abc defx ghi jklx mno"),
- false, 0, 0, false, &diffs);
+ false, 0, 0, false);
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2793479_1)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T("() "));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789012345678901234567890123456789
_T("static int iTranslateBytesToBC (TCHAR* pd, BYTE* src, int srclen);"),
_T("static int iTranslateBytesToBC(TCHAR* pd, const BYTE* src, int srclen);"),
- false, 0, 1, true, &diffs);
+ false, 0, 1, true);
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2793479_2)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T("() "));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789012345678901234567890123456789
_T("static int iTranslateBytesToBC (TCHAR* pd, BYTE* src, int srclen);"),
_T("static int iTranslateBytesToBC(TCHAR* pd, const BYTE* src, int srclen);"),
- false, 0, 1, false, &diffs);
+ false, 0, 1, false);
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 0)
{
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2797067_1)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abc def ghi jkl mno pqr stu vwx yz"),
_T("abc def 123 ghi jkl mno pqr stu 456 vw x yz"),
- false, 0, 0, true, &diffs);
+ false, 0, 0, true);
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 2)
{
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2797067_2)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abc def ghi jkl mno pqr stu vwx yz"),
_T("abc def 123 ghi jkl mno pqr stu 456 vw x yz"),
- false, 0, 0, false, &diffs);
+ false, 0, 0, false);
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 2)
{
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2797067_3)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abc def ghi jkl mno pqr stu vwx yzr"),
_T("abc def 123ghi jkl mno pqr stu 456vwx yzrr"),
- false, 0, 0, true, &diffs);
+ false, 0, 0, true);
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 2)
{
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2797067_4)
{
- std::vector<strdiff::wdiff> diffs;
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abc def ghi jkl mno pqr stu vwx yzr"),
_T("abc def 123ghi jkl mno pqr stu 456vwx yzrr"),
- false, 0, 0, false, &diffs);
+ false, 0, 0, false);
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 2)
{
TEST_F(StringDiffsTestByte, ByteLevel19b3)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(",;"));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 0 1 2 3 4567890123456789012345678901234567890123456789
_T(" wsprintf(buf, _T(left= %s, %d,%d, right= %s, %d,%d ),"),
_T(" if (len2 < 50)"),
- true, 0, 1, true, &diffs);
+ true, 0, 1, true);
EXPECT_EQ(4, diffs.size());
}
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel19b2)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(",;"));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 0 1234567890123456789012345678901234567890123456789
_T(" while (1)"),
- _T(" for (;;)"), true, 0, 1, true, &diffs);
+ _T(" for (;;)"), true, 0, 1, true);
EXPECT_EQ(2, diffs.size());
strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel19b1)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(","));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abcdef,abccef,abcdef,"),
_T("abcdef,abcdef,abcdef,"),
- true, 0, 1, true, &diffs);
+ true, 0, 1, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel20c)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T(""),
_T(" // remove empty records on both side"),
- true, 0, 1, true, &diffs);
+ true, 0, 1, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel20a)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- strdiff::ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T(",;+ der abcdef,der,Thomas,abcdef,abcdef,;"),
_T(",;+ der abcdef,Thomas,accdgf,abcdef,-+"),
- true, 0, 1, true, &diffs);
+ true, 0, 1, true);
EXPECT_EQ(3, diffs.size());
strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel19a)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(","));
- strdiff::ComputeWordDiffs(_T("abcdef,abcdef,abcdef,"), _T("abcdef,abccef,abcdef,"),
- true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcdef,abcdef,abcdef,"), _T("abcdef,abccef,abcdef,"),
+ true, 0, 1, false);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
TEST_F(StringDiffsTestByte, ByteLevel19b)
{
- std::vector<strdiff::wdiff> diffs;
strdiff::SetBreakChars(_T(","));
- strdiff::ComputeWordDiffs(_T("abcdef,abccef,abcdef,"), _T("abcdef,abcdef,abcdef,"),
- true, 0, 1, true, &diffs);
+ std::vector<strdiff::wdiff> diffs = strdiff::ComputeWordDiffs(_T("abcdef,abccef,abcdef,"), _T("abcdef,abcdef,abcdef,"),
+ true, 0, 1, true);
EXPECT_EQ(1, diffs.size());
strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )