CMainFrame::~CMainFrame()
{
GetOptionsMgr()->SaveOption(OPT_TABBAR_AUTO_MAXWIDTH, m_wndTabBar.GetAutoMaxWidth());
- sd_Close();
+ strdiff::Close();
}
#ifdef _UNICODE
theApp.UpdateCodepageModule();
- sd_SetBreakChars(GetOptionsMgr()->GetString(OPT_BREAK_SEPARATORS).c_str());
+ strdiff::SetBreakChars(GetOptionsMgr()->GetString(OPT_BREAK_SEPARATORS).c_str());
// make an attempt at rescanning any open diff sessions
ApplyDiffOptions();
CMergeApp::~CMergeApp()
{
- sd_Close();
+ strdiff::Close();
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMergeApp object
}
}
- sd_Init(); // String diff init
- sd_SetBreakChars(GetOptionsMgr()->GetString(OPT_BREAK_SEPARATORS).c_str());
+ strdiff::Init(); // String diff init
+ strdiff::SetBreakChars(GetOptionsMgr()->GetString(OPT_BREAK_SEPARATORS).c_str());
m_bMergingMode = GetOptionsMgr()->GetBool(OPT_MERGE_MODE);
int breakType = GetBreakType(); // whitespace only or include punctuation
bool byteColoring = GetByteColoringOption();
- std::vector<wdiff> worddiffs;
- sd_ComputeWordDiffs(2, str, casitive, xwhite, breakType, byteColoring, &worddiffs);
+ std::vector<strdiff::wdiff> worddiffs;
+ strdiff::ComputeWordDiffs(2, str, casitive, xwhite, breakType, byteColoring, &worddiffs);
int nDiffLenSum = 0;
- for (std::vector<wdiff>::const_iterator it = worddiffs.begin(); it != worddiffs.end(); ++it)
+ for (std::vector<strdiff::wdiff>::const_iterator it = worddiffs.begin(); it != worddiffs.end(); ++it)
{
nDiffLenSum += it->end[0] - it->begin[0] + 1;
}
int breakType = GetBreakType(); // whitespace only or include punctuation
bool byteColoring = GetByteColoringOption();
- std::vector<wdiff> worddiffs;
+ std::vector<strdiff::wdiff> worddiffs;
// Make the call to stringdiffs, which does all the hard & tedious computations
- sd_ComputeWordDiffs(m_nBuffers, str, casitive, xwhite, breakType, byteColoring, &worddiffs);
+ strdiff::ComputeWordDiffs(m_nBuffers, str, casitive, xwhite, breakType, byteColoring, &worddiffs);
int i;
- std::vector<wdiff>::iterator it;
+ std::vector<strdiff::wdiff>::iterator it;
for (i = 0, it = worddiffs.begin(); it != worddiffs.end(); ++i, ++it)
{
WordDiff wd;
/**
* @file stringdiffs.cpp
*
- * @brief Implementation file for sd_ComputeWordDiffs (q.v.)
+ * @brief Implementation file for ComputeWordDiffs (q.v.)
*
*/
using std::vector;
+namespace strdiff
+{
+
static bool Initialized;
static bool CustomChars;
static TCHAR *BreakChars;
static bool isSafeWhitespace(TCHAR ch);
static bool isWordBreak(int breakType, const TCHAR *str, int index);
-void sd_Init()
+void Init()
{
BreakChars = &BreakCharDefaults[0];
Initialized = true;
}
-void sd_Close()
+void Close()
{
if (CustomChars)
{
Initialized = false;
}
-void sd_SetBreakChars(const TCHAR *breakChars)
+void SetBreakChars(const TCHAR *breakChars)
{
assert(Initialized);
}
void
-sd_ComputeWordDiffs(const String& str1, const String& str2,
+ComputeWordDiffs(const String& str1, const String& str2,
bool case_sensitive, int whitespace, int breakType, bool byte_level,
std::vector<wdiff> * pDiffs)
{
String strs[3] = {str1, str2, _T("")};
- sd_ComputeWordDiffs(2, strs, case_sensitive, whitespace, breakType, byte_level, pDiffs);
+ ComputeWordDiffs(2, strs, case_sensitive, whitespace, breakType, byte_level, pDiffs);
}
struct Comp02Functor
* @brief Construct our worker object and tell it to do the work
*/
void
-sd_ComputeWordDiffs(int nFiles, const String str[3],
+ComputeWordDiffs(int nFiles, const String str[3],
bool case_sensitive, int whitespace, int breakType, bool byte_level,
std::vector<wdiff> * pDiffs)
{
* Assumes whitespace is never leadbyte or trailbyte!
*/
void
-sd_ComputeByteDiff(String & str1, String & str2,
+ComputeByteDiff(String & str1, String & str2,
bool casitive, int xwhite,
int begin[2], int end[2], bool equal)
{
String str1_2, str2_2;
str1_2 = m_str1.substr(diff.begin[0], diff.end[0] - diff.begin[0] + 1);
str2_2 = m_str2.substr(diff.begin[1], diff.end[1] - diff.begin[1] + 1);
- sd_ComputeByteDiff(str1_2, str2_2, m_case_sensitive, m_whitespace, begin, end, false);
+ ComputeByteDiff(str1_2, str2_2, m_case_sensitive, m_whitespace, begin, end, false);
if (begin[0] == -1)
{
// no visible diff on side1
}
}
+}
/**
* @file stringdiffs.h
*
- * @brief Interface file declaring sd_ComputeWordDiffs (q.v.)
+ * @brief Interface file declaring ComputeWordDiffs (q.v.)
*
*/
#pragma once
#include "UnicodeString.h"
#include <vector>
+namespace strdiff
+{
+
/** @brief One difference between two strings */
struct wdiff {
int begin[3]; // 0-based, eg, begin[0] is from str1
}
};
-void sd_Init();
-void sd_Close();
+void Init();
+void Close();
-void sd_SetBreakChars(const TCHAR *breakChars);
+void SetBreakChars(const TCHAR *breakChars);
-void sd_ComputeWordDiffs(const String& str1, const String& str2,
+void ComputeWordDiffs(const String& str1, const String& str2,
bool case_sensitive, int whitespace, int breakType, bool byte_level,
std::vector<wdiff> * pDiffs);
-void sd_ComputeWordDiffs(int nStrings, const String str[3],
+void ComputeWordDiffs(int nStrings, const String str[3],
bool case_sensitive, int whitespace, int breakType, bool byte_level,
std::vector<wdiff> * pDiffs);
-void sd_ComputeByteDiff(const String& str1, const String& str2,
+void ComputeByteDiff(const String& str1, const String& str2,
bool casitive, int xwhite,
int begin[2], int end[2], bool equal);
+
+}
// We don't use _DEBUG since stringdiff logging is verbose and slows down WinMerge
//#define STRINGDIFF_LOGGING
+namespace strdiff
+{
+
/**
* @brief kind of diff blocks.
*/
struct wdiff;
/**
- * @brief Class to hold together data needed to implement sd_ComputeWordDiffs
+ * @brief Class to hold together data needed to implement strdiff::ComputeWordDiffs
*/
class stringdiffs
{
std::vector<word> m_words2;
std::vector<wdiff> m_wdiffs;
};
+
+}
StringDiffsTest()
{
// You can do set-up work for each test here.
- sd_Init();
+ strdiff::Init();
}
virtual ~StringDiffsTest()
{
// You can do clean-up work that doesn't throw exceptions here.
- sd_Close();
+ strdiff::Close();
}
// If the constructor and destructor are not enough for setting up
// Objects declared here can be used by all tests in the test case for Foo.
};
- // sd_ComputeWordDiffs() parameters are:
+ // strdiff::ComputeWordDiffs() parameters are:
// String & str1 - the first string to compare
// String & str2 - the second string to compare
// bool case_sensitive - is the compare case-sensitive?
// int whitespace - do we ignore whitespace and how
// int breakType - Space (0) or punctuations (1) break
// bool byte_level - are we word (false) or byte-level (true) diffing
- // std::vector<wdiff> * pDiffs - resultting diff list
+ // std::vector<strdiff::wdiff> * pDiffs - resultting diff list
// Both strings empty
TEST_F(StringDiffsTest, EmptyBoth)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T(""), _T(""), false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T(""), _T(""), false, 0, 0, false, &diffs);
EXPECT_EQ(0, diffs.size());
}
// First string empty
TEST_F(StringDiffsTest, EmptyFirst)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T(""), _T("abcde"), false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T(""), _T("abcde"), false, 0, 0, false, &diffs);
EXPECT_EQ(1, diffs.size());
}
// Second string empty
TEST_F(StringDiffsTest, EmptySecond)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T("abcde"), _T(""), false, 0, 0, false, &diffs);
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T("abcde"), _T(""), false, 0, 0, false, &diffs);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, no case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, Default1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, DefaultDiffererentLen)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, no case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, DefaultWhitespaceEnd)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, Caseignore1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, CaseignoreCase1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace2)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, no case sensitivity, ignore whitespace change, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace3)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore whitespace change, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace4)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore whitespace change, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace5)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Whitespace at begin of first string is a difference
TEST_F(StringDiffsTest, IgnoreWhitespace6)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
}
// Identical strings, no case sensitivity, ignore whitespace change, words, word-level
TEST_F(StringDiffsTest, IgnoreWhitespace7)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace2)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace3)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace4)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace5)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
/// FIXME:
// EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace6)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, no case sensitivity, ignore all whitespace, words, word-level
TEST_F(StringDiffsTest, IgnoreAllWhitespace7)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(0, diffs.size());
}
// Identical strings, case sensitivity, no whitespace, words, word-level
TEST_F(StringDiffsTest, WordBreak2Words1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(0, pDiff->begin[0]);
// Last word is different
TEST_F(StringDiffsTest, WordBreak2Words2)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(6, pDiff->begin[0]);
// Both words are different
TEST_F(StringDiffsTest, WordBreak2Words3)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(2, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(4, pDiff->end[0]);
// Middle word is different
TEST_F(StringDiffsTest, WordBreak3Words1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(6, pDiff->begin[0]);
// Middle word is different
TEST_F(StringDiffsTest, WordBreak3Words2)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(6, pDiff->begin[0]);
// First two words are different
TEST_F(StringDiffsTest, WordBreak3Words3)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(2, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(4, pDiff->end[0]);
// First two words are different
TEST_F(StringDiffsTest, WordBreak3Words4)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(2, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(4, pDiff->end[0]);
// First and last words are different generating two diffs
TEST_F(StringDiffsTest, WordBreak3Words5)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(2, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 2)
{
EXPECT_EQ(0, pDiff->begin[0]);
// First word is different
TEST_F(StringDiffsTest, PunctBreak2Words1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(0, pDiff->begin[0]);
// First word is different
TEST_F(StringDiffsTest, PunctBreak2Words2)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(0, pDiff->begin[0]);
// Both words are different
TEST_F(StringDiffsTest, PunctBreak2Words3)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(2, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 2)
{
EXPECT_EQ(0, pDiff->begin[0]);
// First word is different
TEST_F(StringDiffsTest, PunctBreak3Words1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(0, pDiff->begin[0]);
// First word is different
TEST_F(StringDiffsTest, PunctBreak3Words2)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(2, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(4, pDiff->end[0]);
// All three words are different
TEST_F(StringDiffsTest, PunctBreak3Words3)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(3, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(4, pDiff->end[0]);
// First word is different
TEST_F(StringDiffsTest, PunctBreak3Words4)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(2, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(4, pDiff->end[0]);
// Match whole strings
TEST_F(StringDiffsTest, CustomPunct1)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(""));
- sd_ComputeWordDiffs(_T("Abcde:fghij"), _T("abcde:fghij"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(""));
+ strdiff::ComputeWordDiffs(_T("Abcde:fghij"), _T("abcde:fghij"), true, 0, 1, false, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(10, pDiff->end[0]);
// Match whole strings
TEST_F(StringDiffsTest, CustomPunct2)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(""));
- sd_ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(""));
+ strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(10, pDiff->end[0]);
// First word is different
TEST_F(StringDiffsTest, CustomPunctBreak1)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(":"));
- sd_ComputeWordDiffs(_T("Abcde:fghij"), _T("abcde:fghij"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(":"));
+ strdiff::ComputeWordDiffs(_T("Abcde:fghij"), _T("abcde:fghij"), true, 0, 1, false, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(0, pDiff->begin[0]);
// First word is different
TEST_F(StringDiffsTest, CustomPunctBreak2)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(";"));
- sd_ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false, &diffs);
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(";"));
+ strdiff::ComputeWordDiffs(_T("Abcde,fghij"), _T("abcde,fghij"), true, 0, 1, false, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(0, pDiff->begin[0]);
// Identical strings, case sensitivity, no whitespace, words, byte-level
TEST_F(StringDiffsTest, ByteLevel1)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_TRUE(diffs.size() == 0);
}
// Identical strings, case sensitivity, no whitespace, words, byte-level
TEST_F(StringDiffsTest, ByteLevel2)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(1, pDiff->begin[0]);
// Identical strings, case sensitivity, no whitespace, words, byte-level
TEST_F(StringDiffsTest, ByteLevel3)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(1, pDiff->begin[0]);
// Identical strings, case sensitivity, no whitespace, words, byte-level
TEST_F(StringDiffsTest, ByteLevel4)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(1, pDiff->begin[0]);
// NOTE NOTE: This is questionable?
TEST_F(StringDiffsTest, ByteLevel5)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(1, pDiff->begin[0]);
// NOTE NOTE: This is questionable?
TEST_F(StringDiffsTest, ByteLevel6)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
if (diffs.size() == 1)
{
EXPECT_EQ(1, pDiff->begin[0]);
// NOTE NOTE: This is questionable?
TEST_F(StringDiffsTest, ByteLevel7)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff;
+ strdiff::wdiff *pDiff;
if (diffs.size() == 1 )
{
pDiff = &diffs[0];
// NOTE NOTE: This is questionable?
TEST_F(StringDiffsTest, ByteLevel8)
{
- std::vector<wdiff> diffs;
- sd_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, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff;
+ strdiff::wdiff *pDiff;
if (diffs.size() == 1)
{
pDiff = &diffs[0];
StringDiffsAddsTest()
{
// You can do set-up work for each test here.
- sd_Init();
+ strdiff::Init();
}
virtual ~StringDiffsAddsTest()
{
// You can do clean-up work that doesn't throw exceptions here.
- sd_Close();
+ strdiff::Close();
}
// If the constructor and destructor are not enough for setting up
// Objects declared here can be used by all tests in the test case for Foo.
};
- // sd_ComputeWordDiffs() parameters are:
+ // strdiff::ComputeWordDiffs() parameters are:
// String & str1 - the first string to compare
// String & str2 - the second string to compare
// bool case_sensitive - is the compare case-sensitive?
// int whitespace - do we ignore whitespace and how
// int breakType - Space (0) or punctuations (1) break
// bool byte_level - are we word (false) or byte-level (true) diffing
- // std::vector<wdiff> * pDiffs - resultting diff list
+ // std::vector<strdiff::wdiff> * pDiffs - resultting diff list
// Char added to begin
TEST_F(StringDiffsAddsTest, AddBeginFirst1)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T("abcdefgh"), _T("1abcdefgh"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("1abcdefgh"),
false, 0, 0, false, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(7, pDiff->end[0]);
// Char added to begin
TEST_F(StringDiffsAddsTest, AddBeginFirst2)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T("1abcdefgh"), _T("abcdefgh"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T("1abcdefgh"), _T("abcdefgh"),
false, 0, 0, false, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(8, pDiff->end[0]);
// Char added to begin
TEST_F(StringDiffsAddsTest, AddBeginFirstChar1)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T("abcdefgh"), _T("1abcdefgh"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("1abcdefgh"),
false, 0, 0, true, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(-1, pDiff->end[0]);
// Char added to begin
TEST_F(StringDiffsAddsTest, AddBeginFirstChar2)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T("1abcdefgh"), _T("abcdefgh"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T("1abcdefgh"), _T("abcdefgh"),
false, 0, 0, true, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(0, pDiff->end[0]);
// Char added to end
TEST_F(StringDiffsAddsTest, AddEndFirst1)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T("abcdefgh"), _T("abcdefgh1"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("abcdefgh1"),
false, 0, 0, false, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(7, pDiff->end[0]);
// Char added to end
TEST_F(StringDiffsAddsTest, AddEndFirst2)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T("abcdefgh1"), _T("abcdefgh"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T("abcdefgh1"), _T("abcdefgh"),
false, 0, 0, false, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(8, pDiff->end[0]);
// Char added to end
TEST_F(StringDiffsAddsTest, AddEndFirstChar1)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T("abcdefgh"), _T("abcdefgh1"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T("abcdefgh"), _T("abcdefgh1"),
false, 0, 0, true, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(8, pDiff->begin[0]);
EXPECT_EQ(8, pDiff->begin[1]);
EXPECT_EQ(7, pDiff->end[0]);
// Char added to end
TEST_F(StringDiffsAddsTest, AddEndFirstChar2)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(_T("abcdefgh1"), _T("abcdefgh"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(_T("abcdefgh1"), _T("abcdefgh"),
false, 0, 0, true, &diffs);
EXPECT_EQ(1, diffs.size());
if (diffs.size() >= 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(8, pDiff->begin[0]);
EXPECT_EQ(8, pDiff->begin[1]);
EXPECT_EQ(8, pDiff->end[0]);
// exchange string left right side only
TEST_F(StringDiffsAddsTest, ExchangeString1a)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- sd_ComputeWordDiffs(_T("N2130 _RobOk=_INT B_AND 512 ;Roboter bereit"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
+ 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);
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(2, pDiff->begin[0]);
EXPECT_EQ(2, pDiff->begin[1]);
EXPECT_EQ(3, pDiff->end[0]);
// exchange string left right side only
TEST_F(StringDiffsAddsTest, ExchangeString1b)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- sd_ComputeWordDiffs(_T("N2040 _RobOk=_INT B_AND 'B1000000000' ;Roboter bereit"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
+ 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);
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(2, pDiff->begin[0]);
EXPECT_EQ(2, pDiff->begin[1]);
EXPECT_EQ(3, pDiff->end[0]);
// exchange string left right side only
TEST_F(StringDiffsAddsTest, ExchangeString2a)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
+ strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789
_T("N1960 IF(R2941==2) OR (R2941==203))"),
_T("N1830 IF((R2941==2) OR (R2941==3) "),
EXPECT_EQ(4, diffs.size());
if (diffs.size() > 3)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(2, pDiff->begin[0]);
EXPECT_EQ(2, pDiff->begin[1]);
EXPECT_EQ(3, pDiff->end[0]);
// exchange string left right side only
TEST_F(StringDiffsAddsTest, ExchangeString2b)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
+ strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789
_T("N1830 IF((R2941==2) OR (R2941==3) "),
_T("N1960 IF(R2941==2) OR (R2941==203))"),
EXPECT_EQ(4, diffs.size());
if (diffs.size() > 3)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(2, pDiff->begin[0]);
EXPECT_EQ(2, pDiff->begin[1]);
EXPECT_EQ(3, pDiff->end[0]);
// new option third run
TEST_F(StringDiffsAddsTest, RunThird)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
+ strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789
_T("(sizeof *new);"),
_T("sizeof(*newob));"),
false, 1, 0, true, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff;
+ strdiff::wdiff *pDiff;
if (diffs.size() == 1)
{
pDiff = &diffs[0];
StringDiffsBugsTest()
{
// You can do set-up work for each test here.
- sd_Init();
+ strdiff::Init();
}
virtual ~StringDiffsBugsTest()
{
// You can do clean-up work that doesn't throw exceptions here.
- sd_Close();
+ strdiff::Close();
}
// If the constructor and destructor are not enough for setting up
// Objects declared here can be used by all tests in the test case for Foo.
};
- // sd_ComputeWordDiffs() parameters are:
+ // strdiff::ComputeWordDiffs() parameters are:
// String & str1 - the first string to compare
// String & str2 - the second string to compare
// bool case_sensitive - is the compare case-sensitive?
// int whitespace - do we ignore whitespace and how
// int breakType - Space (0) or punctuations (1) break
// bool byte_level - are we word (false) or byte-level (true) diffing
- // std::vector<wdiff> * pDiffs - resultting diff list
+ // std::vector<strdiff::wdiff> * pDiffs - resultting diff list
// Sf.net bug #1685466 - char level diff
// (ENUMRESLANGPROC) added to middle
TEST_F(StringDiffsBugsTest, Bug_1685466_1)
{
- std::vector<wdiff> diffs;
- sd_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)"),
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(83, pDiff->begin[0]);
EXPECT_EQ(83, pDiff->begin[1]);
EXPECT_EQ(99, pDiff->end[0]);
// (ENUMRESLANGPROC) added to middle
TEST_F(StringDiffsBugsTest, Bug_1685466_2)
{
- std::vector<wdiff> diffs;
- sd_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)"),
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(83, pDiff->begin[0]);
EXPECT_EQ(83, pDiff->begin[1]);
EXPECT_EQ(114, pDiff->end[0]);
// various changes
TEST_F(StringDiffsBugsTest, Bug_1939279_1)
{
- std::vector<wdiff> diffs;
- sd_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\"]"),
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(39, pDiff->begin[0]);
EXPECT_EQ(39, pDiff->begin[1]);
EXPECT_EQ(39, pDiff->end[0]);
// various changes
TEST_F(StringDiffsBugsTest, Bug_1939279_2)
{
- std::vector<wdiff> diffs;
- sd_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\"]"),
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(21, pDiff->begin[0]);
EXPECT_EQ(21, pDiff->begin[1]);
EXPECT_EQ(39, pDiff->end[0]);
// Chars added to end
TEST_F(StringDiffsBugsTest, Bug_2022935)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(
// 012345678901234567890
_T("N42=Import"),
_T("N42=Importuj"),
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(10, pDiff->begin[0]);
EXPECT_EQ(10, pDiff->begin[1]);
EXPECT_EQ(9, pDiff->end[0]);
// Char added to end
TEST_F(StringDiffsBugsTest, Bug_2638045)
{
- std::vector<wdiff> diffs;
- sd_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"),
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(46, pDiff->end[0]);
// Char added to end
TEST_F(StringDiffsBugsTest, Bug_2638045_2)
{
- std::vector<wdiff> diffs;
- sd_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"),
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(46, pDiff->end[0]);
// Char added to end
TEST_F(StringDiffsBugsTest, Bug_2638045_3)
{
- std::vector<wdiff> diffs;
- sd_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"),
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(47, pDiff->begin[0]);
EXPECT_EQ(47, pDiff->begin[1]);
EXPECT_EQ(46, pDiff->end[0]);
// Char added to end
TEST_F(StringDiffsBugsTest, Bug_2638045_4)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T("/"));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T("/"));
+ 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"),
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(44, pDiff->begin[0]);
EXPECT_EQ(44, pDiff->begin[1]);
EXPECT_EQ(46, pDiff->end[0]);
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2779834_1)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("if (nDiff < m_diffs.size())"),
_T("if(nDiff < (int) m_diffs.size())"),
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(1, pDiff->end[0]);
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2779834_2)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("if (nDiff < m_diffs.size())"),
_T("if(nDiff < (int) m_diffs.size())"),
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(2, pDiff->begin[0]);
EXPECT_EQ(2, pDiff->begin[1]);
EXPECT_EQ(1, pDiff->end[0]);
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2783185_1)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("const string ManualFolder = \"Manual\";"),
_T("private const string ManualFolder = \"Manual\";"),
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(-1, pDiff->end[0]);
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2783185_2)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("const string ManualFolder = \"Manual\";"),
_T("private const string ManualFolder = \"Manual\";"),
EXPECT_EQ(1, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(0, pDiff->begin[0]);
EXPECT_EQ(0, pDiff->begin[1]);
EXPECT_EQ(-1, pDiff->end[0]);
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2791879_1)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abc def ghi jkl mno"),
_T("abc defx ghi jklx mno"),
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(7, pDiff->begin[0]);
EXPECT_EQ(7, pDiff->begin[1]);
EXPECT_EQ(6, pDiff->end[0]);
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2791879_2)
{
- std::vector<wdiff> diffs;
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abc def ghi jkl mno"),
_T("abc defx ghi jklx mno"),
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(4, pDiff->begin[0]);
EXPECT_EQ(4, pDiff->begin[1]);
EXPECT_EQ(6, pDiff->end[0]);
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2793479_1)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T("() "));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T("() "));
+ strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789012345678901234567890123456789
_T("static int iTranslateBytesToBC (TCHAR* pd, BYTE* src, int srclen);"),
_T("static int iTranslateBytesToBC(TCHAR* pd, const BYTE* src, int srclen);"),
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 1)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(30, pDiff->begin[0]);
EXPECT_EQ(30, pDiff->begin[1]);
EXPECT_EQ(30, pDiff->end[0]);
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2793479_2)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T("() "));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T("() "));
+ strdiff::ComputeWordDiffs(
// 0123456789012345678901234567890123456789012345678901234567890123456789
_T("static int iTranslateBytesToBC (TCHAR* pd, BYTE* src, int srclen);"),
_T("static int iTranslateBytesToBC(TCHAR* pd, const BYTE* src, int srclen);"),
EXPECT_EQ(2, diffs.size());
if (diffs.size() > 0)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(30, pDiff->begin[0]);
EXPECT_EQ(30, pDiff->begin[1]);
EXPECT_EQ(30, pDiff->end[0]);
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2797067_1)
{
- std::vector<wdiff> diffs;
- sd_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"),
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 2)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(8, pDiff->begin[0]);
EXPECT_EQ(8, pDiff->begin[1]);
EXPECT_EQ(7, pDiff->end[0]);
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2797067_2)
{
- std::vector<wdiff> diffs;
- sd_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"),
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 2)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(8, pDiff->begin[0]);
EXPECT_EQ(8, pDiff->begin[1]);
EXPECT_EQ(7, pDiff->end[0]);
// char-diff
TEST_F(StringDiffsBugsTest, Bug_2797067_3)
{
- std::vector<wdiff> diffs;
- sd_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"),
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 2)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(8, pDiff->begin[0]);
EXPECT_EQ(8, pDiff->begin[1]);
EXPECT_EQ(7, pDiff->end[0]);
// word-diff
TEST_F(StringDiffsBugsTest, Bug_2797067_4)
{
- std::vector<wdiff> diffs;
- sd_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"),
EXPECT_EQ(3, diffs.size());
if (diffs.size() > 2)
{
- wdiff *pDiff = &diffs[0];
+ strdiff::wdiff *pDiff = &diffs[0];
EXPECT_EQ(8, pDiff->begin[0]);
EXPECT_EQ(8, pDiff->begin[1]);
EXPECT_EQ(10, pDiff->end[0]);
StringDiffsTestByte()
{
// You can do set-up work for each test here.
- sd_Init();
+ strdiff::Init();
}
virtual ~StringDiffsTestByte()
{
// You can do clean-up work that doesn't throw exceptions here.
- sd_Close();
+ strdiff::Close();
}
// If the constructor and destructor are not enough for setting up
// Objects declared here can be used by all tests in the test case for Foo.
};
- // sd_ComputeWordDiffs() parameters are:
+ // strdiff::ComputeWordDiffs() parameters are:
// String & str1 - the first string to compare
// String & str2 - the second string to compare
// bool case_sensitive - is the compare case-sensitive?
// int whitespace - do we ignore whitespace and how
// int breakType - Space (0) or punctuations (1) break
// bool byte_level - are we word (false) or byte-level (true) diffing
- // std::vector<wdiff> * pDiffs - resultting diff list
+ // std::vector<strdiff::wdiff> * pDiffs - resultting diff list
TEST_F(StringDiffsTestByte, ByteLevel19b3)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(",;"));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(",;"));
+ strdiff::ComputeWordDiffs(
// 0 1 2 3 4567890123456789012345678901234567890123456789
_T(" wsprintf(buf, _T(left= %s, %d,%d, right= %s, %d,%d ),"),
_T(" if (len2 < 50)"),
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel19b2)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(",;"));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(",;"));
+ strdiff::ComputeWordDiffs(
// 0 1234567890123456789012345678901234567890123456789
_T(" while (1)"),
_T(" for (;;)"), true, 0, 1, true, &diffs);
EXPECT_EQ(2, diffs.size());
- wdiff *pDiff;
+ strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
{
pDiff = &diffs[0];
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel19b1)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(","));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(","));
+ strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T("abcdef,abccef,abcdef,"),
_T("abcdef,abcdef,abcdef,"),
true, 0, 1, true, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff;
+ strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
{
pDiff = &diffs[0];
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel20c)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
+ strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T(""),
_T(" // remove empty records on both side"),
true, 0, 1, true, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff;
+ strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
{
pDiff = &diffs[0];
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel20a)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
- sd_ComputeWordDiffs(
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(".,;:()[]{}!@#\"$%^&*~+-=<>\'/\\|"));
+ strdiff::ComputeWordDiffs(
// 01234567890123456789012345678901234567890123456789
_T(",;+ der abcdef,der,Thomas,abcdef,abcdef,;"),
_T(",;+ der abcdef,Thomas,accdgf,abcdef,-+"),
true, 0, 1, true, &diffs);
EXPECT_EQ(3, diffs.size());
- wdiff *pDiff;
+ strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
{
pDiff = &diffs[0];
// Second word is different
TEST_F(StringDiffsTestByte, ByteLevel19a)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(","));
- sd_ComputeWordDiffs(_T("abcdef,abcdef,abcdef,"), _T("abcdef,abccef,abcdef,"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(","));
+ strdiff::ComputeWordDiffs(_T("abcdef,abcdef,abcdef,"), _T("abcdef,abccef,abcdef,"),
true, 0, 1, false, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff;
+ strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
{
pDiff = &diffs[0];
TEST_F(StringDiffsTestByte, ByteLevel19b)
{
- std::vector<wdiff> diffs;
- sd_SetBreakChars(_T(","));
- sd_ComputeWordDiffs(_T("abcdef,abccef,abcdef,"), _T("abcdef,abcdef,abcdef,"),
+ std::vector<strdiff::wdiff> diffs;
+ strdiff::SetBreakChars(_T(","));
+ strdiff::ComputeWordDiffs(_T("abcdef,abccef,abcdef,"), _T("abcdef,abcdef,abcdef,"),
true, 0, 1, true, &diffs);
EXPECT_EQ(1, diffs.size());
- wdiff *pDiff;
+ strdiff::wdiff *pDiff;
if (diffs.size() >= 1 )
{
pDiff = &diffs[0];