diff --git a/Src/CompareEngines/ByteCompare.cpp b/Src/CompareEngines/ByteCompare.cpp index 9e285fe6ce1..c0f2b80be54 100644 --- a/Src/CompareEngines/ByteCompare.cpp +++ b/Src/CompareEngines/ByteCompare.cpp @@ -15,6 +15,7 @@ #include "DiffContext.h" #include "diff.h" #include "ByteComparator.h" +#include "DiffFileData.h" namespace CompareEngines { @@ -24,15 +25,12 @@ static const int KILO = 1024; // Kilo(byte) /** @brief Quick contents compare's file buffer size. */ static const int WMCMPBUFF = 32 * KILO; -static void CopyTextStats(const FileTextStats * stats, FileTextStats * myTextStats); - /** * @brief Default constructor. */ ByteCompare::ByteCompare() : m_pOptions(nullptr) , m_piAbortable(nullptr) - , m_inf(nullptr) { } @@ -68,30 +66,15 @@ void ByteCompare::SetAbortable(const IAbortable * piAbortable) m_piAbortable = const_cast(piAbortable); } -/** - * @brief Set filedata. - * @param [in] items Count of filedata items to set. - * @param [in] data File data. - * @note Path names are set by SetPaths() function. - */ -void ByteCompare::SetFileData(int items, file_data *data) -{ - // We support only two files currently! - assert(items == 2); - m_inf = data; - m_textStats[0].clear(); - m_textStats[1].clear(); -} - - /** * @brief Compare two specified files, byte-by-byte - * @param [in] bStopAfterFirstDiff Stop compare after we find first difference? - * @param [in] piAbortable Interface allowing to abort compare * @return DIFFCODE */ -int ByteCompare::CompareFiles(FileLocation *location) +int ByteCompare::CompareFiles(DiffFileData* diffData) { + diffData->m_textStats[0].clear(); + diffData->m_textStats[1].clear(); + // TODO // Right now, we assume files are in 8-bit encoding // because transform code converted any UCS-2 files to UTF-8 @@ -137,18 +120,18 @@ int ByteCompare::CompareFiles(FileLocation *location) { // Assume our blocks are in range of int int space = sizeof(buff[i])/sizeof(buff[i][0]) - (int) bfend[i]; - int rtn = cio::read_i(m_inf[i].desc, &buff[i][bfend[i]], space); + int rtn = cio::read_i(diffData->m_inf[i].desc, &buff[i][bfend[i]], space); if (rtn == -1) return DIFFCODE::CMPERR; if (rtn < space) eof[i] = true; bfend[i] += rtn; - if (m_inf[0].desc == m_inf[1].desc) + if (diffData->m_inf[0].desc == diffData->m_inf[1].desc) { bfstart[1] = bfstart[0]; bfend[1] = bfend[0]; eof[1] = eof[0]; - location[1] = location[0]; + diffData->m_FileLocation[1] = diffData->m_FileLocation[0]; memcpy(&buff[1][bfend[1] - rtn], &buff[0][bfend[0] - rtn], rtn); break; } @@ -170,7 +153,7 @@ int ByteCompare::CompareFiles(FileLocation *location) int64_t offset1 = (ptr1 - &buff[1][0]); // are these two buffers the same? - int result = comparator.CompareBuffers(m_textStats[0], m_textStats[1], + int result = comparator.CompareBuffers(diffData->m_textStats[0], diffData->m_textStats[1], ptr0, ptr1, end0, end1, eof[0], eof[1], offset0, offset1); if (result == ByteComparator::RESULT_DIFF) { @@ -253,8 +236,8 @@ int ByteCompare::CompareFiles(FileLocation *location) // then the result is reliable. if (eof[0] && eof[1]) { - bool bBin0 = (m_textStats[0].nzeros > 0); - bool bBin1 = (m_textStats[1].nzeros > 0); + bool bBin0 = (diffData->m_textStats[0].nzeros > 0); + bool bBin1 = (diffData->m_textStats[1].nzeros > 0); if (bBin0 && bBin1) diffcode |= DIFFCODE::BIN | DIFFCODE::BINSIDE1 | DIFFCODE::BINSIDE2; @@ -277,25 +260,4 @@ int ByteCompare::CompareFiles(FileLocation *location) return diffcode; } -/** - * @brief Copy text stat results from diffutils back into the FileTextStats structure - */ -static void CopyTextStats(const FileTextStats * stats, FileTextStats * myTextStats) -{ - myTextStats->ncrlfs = stats->ncrlfs; - myTextStats->ncrs = stats->ncrs; - myTextStats->nlfs = stats->nlfs; - myTextStats->nzeros = stats->nzeros; -} - -/** - * @brief Return text statistics for last compare. - * @param [in] side For which file to return statistics. - * @param [out] stats Stats as asked. - */ -void ByteCompare::GetTextStats(int side, FileTextStats *stats) const -{ - CopyTextStats(&m_textStats[side], stats); -} - } // namespace CompareEngines diff --git a/Src/CompareEngines/ByteCompare.h b/Src/CompareEngines/ByteCompare.h index 39bac53bf59..154ca2a4297 100644 --- a/Src/CompareEngines/ByteCompare.h +++ b/Src/CompareEngines/ByteCompare.h @@ -11,8 +11,7 @@ class CompareOptions; class QuickCompareOptions; class IAbortable; -struct FileLocation; -struct file_data; +struct DiffFileData; namespace CompareEngines { @@ -31,16 +30,12 @@ class ByteCompare void SetCompareOptions(const CompareOptions & options); void SetAdditionalOptions(bool stopAfterFirstDiff); void SetAbortable(const IAbortable * piAbortable); - void SetFileData(int items, file_data *data); - int CompareFiles(FileLocation *location); - void GetTextStats(int side, FileTextStats *stats) const; + + int CompareFiles(DiffFileData* diffData); private: std::unique_ptr m_pOptions; /**< Compare options for diffutils. */ IAbortable * m_piAbortable; - file_data * m_inf; /**< Compared files data (for diffutils). */ - FileTextStats m_textStats[2]; - }; } // namespace CompareEngines diff --git a/Src/CompareEngines/Wrap_DiffUtils.cpp b/Src/CompareEngines/Wrap_DiffUtils.cpp index a0a22e9f009..5ac57fd8c27 100644 --- a/Src/CompareEngines/Wrap_DiffUtils.cpp +++ b/Src/CompareEngines/Wrap_DiffUtils.cpp @@ -21,6 +21,7 @@ #include "DiffWrapper.h" #include "xdiff_gnudiff_compat.h" #include "unicoder.h" +#include "DiffFileData.h" namespace CompareEngines { @@ -30,9 +31,7 @@ static void CopyTextStats(const file_data * inf, FileTextStats * myTextStats); * @brief Default constructor. */ DiffUtils::DiffUtils() - : m_pOptions(nullptr) - , m_inf(nullptr) - , m_pDiffWrapper(new ::CDiffWrapper) + : m_pDiffWrapper(new ::CDiffWrapper) , m_ndiffs(0) , m_ntrivialdiffs(0) { @@ -49,10 +48,11 @@ DiffUtils::~DiffUtils() * @brief Set compare options from general compare options. * @param [in ]options General compare options. */ -void DiffUtils::SetCompareOptions(const CompareOptions & options) +void DiffUtils::SetCompareOptions(const CompareOptions& options) { - m_pOptions.reset(new DiffutilsOptions(static_cast(options))); - m_pOptions->SetToDiffUtils(); + DIFFOPTIONS doptions; + static_cast(options).GetAsDiffOptions(doptions); + m_pDiffWrapper->SetOptions(&doptions); } /** @@ -88,30 +88,18 @@ void DiffUtils::SetCodepage(int codepage) m_pDiffWrapper->SetCodepage(codepage); } -/** - * @brief Set filedata. - * @param [in] items Count of filedata items to set. - * @param [in] data File data. - */ -void DiffUtils::SetFileData(int items, file_data *data) -{ - // We support only two files currently! - assert(items == 2); - m_inf = data; -} - /** * @brief Compare two files (as earlier specified). * @return DIFFCODE as a result of compare. */ -int DiffUtils::diffutils_compare_files() +int DiffUtils::CompareFiles(DiffFileData* diffData) { int bin_flag = 0; int bin_file = 0; // bitmap for binary files // Do the actual comparison (generating a change script) struct change *script = nullptr; - bool success = Diff2Files(&script, 0, &bin_flag, false, &bin_file); + bool success = m_pDiffWrapper->Diff2Files(&script, diffData, & bin_flag, & bin_file); if (!success) { return DIFFCODE::FILE | DIFFCODE::TEXT | DIFFCODE::CMPERR; @@ -125,19 +113,16 @@ int DiffUtils::diffutils_compare_files() if (script != nullptr) { - const bool usefilters = m_pOptions->m_filterCommentsLines || + const bool usefilters = m_pDiffWrapper->GetOptions().m_filterCommentsLines || (m_pDiffWrapper->GetFilterList() && m_pDiffWrapper->GetFilterList()->HasRegExps()) || (m_pDiffWrapper->GetSubstitutionList() && m_pDiffWrapper->GetSubstitutionList()->HasRegExps()); PostFilterContext ctxt{}; - String Ext = ucr::toTString(m_inf[0].name); + String Ext = ucr::toTString(diffData->m_inf[0].name); size_t PosOfDot = Ext.rfind('.'); if (PosOfDot != String::npos) Ext.erase(0, PosOfDot + 1); - DIFFOPTIONS options = {0}; - m_pOptions->GetAsDiffOptions(options); - m_pDiffWrapper->SetOptions(&options); m_pDiffWrapper->SetFilterCommentsSourceDef(Ext); struct change *next = script; @@ -159,13 +144,13 @@ int DiffUtils::diffutils_compare_files() { /* Determine range of line numbers involved in each file. */ int first0 = 0, last0 = 0, first1 = 0, last1 = 0, deletes = 0, inserts = 0; - analyze_hunk (thisob, &first0, &last0, &first1, &last1, &deletes, &inserts, m_inf); + analyze_hunk (thisob, &first0, &last0, &first1, &last1, &deletes, &inserts, diffData->m_inf); if (deletes!=0 || inserts!=0 || thisob->trivial!=0) { /* Print the lines that the first file has. */ int trans_a0 = 0, trans_b0 = 0, trans_a1 = 0, trans_b1 = 0; - translate_range(&m_inf[0], first0, last0, &trans_a0, &trans_b0); - translate_range(&m_inf[1], first1, last1, &trans_a1, &trans_b1); + translate_range(&diffData->m_inf[0], first0, last0, &trans_a0, &trans_b0); + translate_range(&diffData->m_inf[1], first1, last1, &trans_a1, &trans_b1); //Determine quantity of lines in this block for both sides int QtyLinesLeft = (trans_b0 - trans_a0) + 1; @@ -177,7 +162,7 @@ int DiffUtils::diffutils_compare_files() op = OP_TRIVIAL; else op = OP_DIFF; - m_pDiffWrapper->PostFilter(ctxt, trans_a0 - 1, QtyLinesLeft, trans_a1 - 1, QtyLinesRight, op, m_inf); + m_pDiffWrapper->PostFilter(ctxt, trans_a0 - 1, QtyLinesLeft, trans_a1 - 1, QtyLinesRight, op, diffData->m_inf); if(op == OP_TRIVIAL) { thisob->trivial = 1; @@ -261,31 +246,10 @@ int DiffUtils::diffutils_compare_files() second file if first is binary). * @return `true` when compare succeeds, `false` if error happened during compare. */ -bool DiffUtils::Diff2Files(struct change ** diffs, int depth, - int * bin_status, bool bMovedBlocks, int * bin_file) const +bool DiffUtils::Diff2Files(struct change ** diffs, DiffFileData *diffData, + int * bin_status, int * bin_file) const { - bool bRet = true; - SE_Handler seh; - try - { - if (m_pOptions->m_diffAlgorithm != DIFF_ALGORITHM_DEFAULT) - { - const unsigned xdl_flags = make_xdl_flags(*m_pOptions); - *diffs = diff_2_files_xdiff(m_inf, bin_status, bMovedBlocks, bin_file, xdl_flags); - files[0] = m_inf[0]; - files[1] = m_inf[1]; - } - else - { - *diffs = diff_2_files(m_inf, depth, bin_status, bMovedBlocks, bin_file); - } - } - catch (SE_Exception&) - { - *diffs = nullptr; - bRet = false; - } - return bRet; + return m_pDiffWrapper->Diff2Files(diffs, diffData, bin_status, bin_file); } /** @@ -310,14 +274,5 @@ void DiffUtils::GetDiffCounts(int & diffs, int & trivialDiffs) const trivialDiffs = m_ntrivialdiffs; } -/** - * @brief Return text statistics for last compare. - * @param [in] side For which file to return statistics. - * @param [out] stats Stats as asked. - */ -void DiffUtils::GetTextStats(int side, FileTextStats *stats) const -{ - CopyTextStats(&m_inf[side], stats); -} } // namespace CompareEngines diff --git a/Src/CompareEngines/Wrap_DiffUtils.h b/Src/CompareEngines/Wrap_DiffUtils.h index a7dda80cda8..7ed6c518122 100644 --- a/Src/CompareEngines/Wrap_DiffUtils.h +++ b/Src/CompareEngines/Wrap_DiffUtils.h @@ -7,13 +7,12 @@ #include -class CompareOptions; class FilterList; class SubstitutionList; -class DiffutilsOptions; -struct file_data; +class CompareOptions; struct FileTextStats; class CDiffWrapper; +struct DiffFileData; namespace CompareEngines { @@ -31,22 +30,21 @@ class DiffUtils public: DiffUtils(); ~DiffUtils(); - void SetCompareOptions(const CompareOptions & options); + + void SetCodepage(int codepage); + void SetCompareOptions(const CompareOptions& options); void SetFilterList(std::shared_ptr plist); void ClearFilterList(); void SetSubstitutionList(std::shared_ptr plist); void ClearSubstitutionList(); - void SetFileData(int items, file_data *data); - int diffutils_compare_files(); + + int CompareFiles(DiffFileData* diffData); + bool Diff2Files(struct change ** diffs, DiffFileData *diffData, + int * bin_status, int * bin_file) const; + void GetDiffCounts(int & diffs, int & trivialDiffs) const; - void GetTextStats(int side, FileTextStats *stats) const; - bool Diff2Files(struct change ** diffs, int depth, - int * bin_status, bool bMovedBlocks, int * bin_file) const; - void SetCodepage(int codepage); private: - std::unique_ptr m_pOptions; /**< Compare options for diffutils. */ - file_data * m_inf; /**< Compared files data (for diffutils). */ int m_ndiffs; /**< Real diffs found. */ int m_ntrivialdiffs; /**< Ignored diffs found. */ std::unique_ptr m_pDiffWrapper; diff --git a/Src/CompareOptions.cpp b/Src/CompareOptions.cpp index ca4b1432b50..879ded5136e 100644 --- a/Src/CompareOptions.cpp +++ b/Src/CompareOptions.cpp @@ -186,6 +186,7 @@ void DiffutilsOptions::GetAsDiffOptions(DIFFOPTIONS &options) const options.bIgnoreCase = m_bIgnoreCase; options.bIgnoreEol = m_bIgnoreEOLDifference; options.bIgnoreNumbers = m_bIgnoreNumbers; + options.nDiffAlgorithm = m_diffAlgorithm; switch (m_ignoreWhitespace) { diff --git a/Src/DiffWrapper.h b/Src/DiffWrapper.h index 77b69da6cd5..d00329718b0 100644 --- a/Src/DiffWrapper.h +++ b/Src/DiffWrapper.h @@ -163,6 +163,7 @@ class CDiffWrapper void SetCreatePatchFile(const String &filename); void SetCreateDiffList(DiffList *diffList); void GetOptions(DIFFOPTIONS *options) const; + const DiffutilsOptions& GetOptions() const { return m_options; } void SetOptions(const DIFFOPTIONS *options); void SetTextForAutomaticPrediff(const String &text); void SetPrediffer(const PrediffingInfo * prediffer = nullptr); @@ -193,11 +194,11 @@ class CDiffWrapper void EnablePlugins(bool enable); void PostFilter(PostFilterContext& ctxt, int LineNumberLeft, int QtyLinesLeft, int LineNumberRight, int QtyLinesRight, OP_TYPE &Op, const file_data *file_data_ary) const; + bool Diff2Files(struct change ** diffs, DiffFileData *diffData, + int * bin_status, int * bin_file) const; protected: String FormatSwitchString() const; - bool Diff2Files(struct change ** diffs, DiffFileData *diffData, - int * bin_status, int * bin_file) const; void LoadWinMergeDiffsFromDiffUtilsScript(struct change * script, const file_data * inf); void WritePatchFile(struct change * script, file_data * inf); public: diff --git a/Src/FolderCmp.cpp b/Src/FolderCmp.cpp index 36724405658..4a3fd5ec80d 100644 --- a/Src/FolderCmp.cpp +++ b/Src/FolderCmp.cpp @@ -220,11 +220,8 @@ int FolderCmp::prepAndCompareFiles(DIFFITEM &di) } if (tFiles.GetSize() == 2) { - m_pDiffUtilsEngine->SetFileData(2, m_diffFileData.m_inf); - code = m_pDiffUtilsEngine->diffutils_compare_files(); + code = m_pDiffUtilsEngine->CompareFiles(&m_diffFileData); m_pDiffUtilsEngine->GetDiffCounts(m_ndiffs, m_ntrivialdiffs); - m_pDiffUtilsEngine->GetTextStats(0, &m_diffFileData.m_textStats[0]); - m_pDiffUtilsEngine->GetTextStats(1, &m_diffFileData.m_textStats[1]); // If unique item, it was being compared to itself to determine encoding // and the #diffs is invalid @@ -239,20 +236,12 @@ int FolderCmp::prepAndCompareFiles(DIFFITEM &di) bool bRet; int bin_flag10 = 0, bin_flag12 = 0, bin_flag02 = 0; - m_pDiffUtilsEngine->SetFileData(2, diffdata10.m_inf); - bRet = m_pDiffUtilsEngine->Diff2Files(&script10, 0, &bin_flag10, false, nullptr); - m_pDiffUtilsEngine->GetTextStats(0, &m_diffFileData.m_textStats[1]); - m_pDiffUtilsEngine->GetTextStats(1, &m_diffFileData.m_textStats[0]); - - m_pDiffUtilsEngine->SetFileData(2, diffdata12.m_inf); - bRet = m_pDiffUtilsEngine->Diff2Files(&script12, 0, &bin_flag12, false, nullptr); - m_pDiffUtilsEngine->GetTextStats(0, &m_diffFileData.m_textStats[1]); - m_pDiffUtilsEngine->GetTextStats(1, &m_diffFileData.m_textStats[2]); - - m_pDiffUtilsEngine->SetFileData(2, diffdata02.m_inf); - bRet = m_pDiffUtilsEngine->Diff2Files(&script02, 0, &bin_flag02, false, nullptr); - m_pDiffUtilsEngine->GetTextStats(0, &m_diffFileData.m_textStats[0]); - m_pDiffUtilsEngine->GetTextStats(1, &m_diffFileData.m_textStats[2]); + bRet = m_pDiffUtilsEngine->Diff2Files(&script10, &diffdata10, &bin_flag10, nullptr); + bRet = m_pDiffUtilsEngine->Diff2Files(&script12, &diffdata12, &bin_flag12, nullptr); + bRet = m_pDiffUtilsEngine->Diff2Files(&script02, &diffdata02, &bin_flag02, nullptr); + m_diffFileData.m_textStats[0] = diffdata10.m_textStats[1]; + m_diffFileData.m_textStats[1] = diffdata12.m_textStats[0]; + m_diffFileData.m_textStats[2] = diffdata02.m_textStats[1]; code = DIFFCODE::FILE; @@ -336,13 +325,8 @@ int FolderCmp::prepAndCompareFiles(DIFFITEM &di) } if (tFiles.GetSize() == 2) { - m_pByteCompare->SetFileData(2, m_diffFileData.m_inf); - // use our own byte-by-byte compare - code = m_pByteCompare->CompareFiles(m_diffFileData.m_FileLocation); - - m_pByteCompare->GetTextStats(0, &m_diffFileData.m_textStats[0]); - m_pByteCompare->GetTextStats(1, &m_diffFileData.m_textStats[1]); + code = m_pByteCompare->CompareFiles(&m_diffFileData); // Quick contents doesn't know about diff counts // Set to special value to indicate invalid @@ -351,32 +335,17 @@ int FolderCmp::prepAndCompareFiles(DIFFITEM &di) } else { - // 10 - m_pByteCompare->SetFileData(2, diffdata10.m_inf); - // use our own byte-by-byte compare - int code10 = m_pByteCompare->CompareFiles(diffdata10.m_FileLocation); - - m_pByteCompare->GetTextStats(0, &m_diffFileData.m_textStats[1]); - m_pByteCompare->GetTextStats(1, &m_diffFileData.m_textStats[0]); - + // 10 + int code10 = m_pByteCompare->CompareFiles(&diffdata10); // 12 - m_pByteCompare->SetFileData(2, diffdata12.m_inf); - - // use our own byte-by-byte compare - int code12 = m_pByteCompare->CompareFiles(diffdata12.m_FileLocation); - - m_pByteCompare->GetTextStats(0, &m_diffFileData.m_textStats[1]); - m_pByteCompare->GetTextStats(1, &m_diffFileData.m_textStats[2]); - + int code12 = m_pByteCompare->CompareFiles(&diffdata12); // 02 - m_pByteCompare->SetFileData(2, diffdata02.m_inf); - - // use our own byte-by-byte compare - int code02 = m_pByteCompare->CompareFiles(diffdata02.m_FileLocation); + int code02 = m_pByteCompare->CompareFiles(&diffdata02); - m_pByteCompare->GetTextStats(0, &m_diffFileData.m_textStats[0]); - m_pByteCompare->GetTextStats(1, &m_diffFileData.m_textStats[2]); + m_diffFileData.m_textStats[0] = diffdata10.m_textStats[1]; + m_diffFileData.m_textStats[1] = diffdata12.m_textStats[0]; + m_diffFileData.m_textStats[2] = diffdata02.m_textStats[1]; code = DIFFCODE::FILE; if (DIFFCODE::isResultError(code10) || DIFFCODE::isResultError(code12) || DIFFCODE::isResultError(code02)) diff --git a/Testing/GoogleTest/ByteCompare/ByteCompare_test.cpp b/Testing/GoogleTest/ByteCompare/ByteCompare_test.cpp index ca8eafec184..803964c0a72 100644 --- a/Testing/GoogleTest/ByteCompare/ByteCompare_test.cpp +++ b/Testing/GoogleTest/ByteCompare/ByteCompare_test.cpp @@ -5,6 +5,7 @@ #include "CompareOptions.h" #include "FileLocation.h" #include "DiffItem.h" +#include "DiffFileData.h" #include "cio.h" #include "unicoder.h" #include @@ -31,18 +32,14 @@ namespace { FilePair(const std::string& left, const std::string& right) { - cio::tsopen_s(&filedata[0].desc, ucr::toTString(left), O_RDONLY | O_BINARY, _SH_DENYWR, _S_IREAD); - cio::tsopen_s(&filedata[1].desc, ucr::toTString(right), O_RDONLY | O_BINARY, _SH_DENYWR, _S_IREAD); + diffData.OpenFiles(ucr::toTString(left), ucr::toTString(right)); } ~FilePair() { - cio::close(filedata[0].desc); - cio::close(filedata[1].desc); } - FileLocation location[2]; - file_data filedata[2]; + DiffFileData diffData; }; // The fixture for testing paths functions. @@ -118,13 +115,12 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); bc.SetCompareOptions(option); - EXPECT_EQ(DIFFCODE::BIN|DIFFCODE::BINSIDE1|DIFFCODE::BINSIDE2|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::BIN|DIFFCODE::BINSIDE1|DIFFCODE::BINSIDE2|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); FileTextStats stats[2]; - bc.GetTextStats(0, &stats[0]); - bc.GetTextStats(1, &stats[1]); + stats[0] = pair.diffData.m_textStats[0]; + stats[1] = pair.diffData.m_textStats[1]; // EXPECT_EQ(3, stats[0].nzeros); // EXPECT_EQ(3, stats[1].nzeros); @@ -176,9 +172,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } {// diff @@ -188,9 +183,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } {// all space @@ -201,9 +195,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } {// empty right @@ -213,9 +206,8 @@ namespace TempFile file_right(filename_right, "", 0); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } {// empty left @@ -225,9 +217,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } { @@ -238,9 +229,8 @@ namespace TempFile file_right(filename_right, "A", 1); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } { @@ -251,9 +241,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } } @@ -300,9 +289,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } {// diff @@ -313,9 +301,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } {// same2 @@ -337,9 +324,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } {// same3 @@ -361,9 +347,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } } @@ -391,8 +376,7 @@ namespace } FilePair pair(filename_crlf, filename_lf); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } // diff @@ -409,8 +393,7 @@ namespace } FilePair pair(filename_crlf, filename_lf); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } remove(filename_crlf.c_str()); @@ -443,9 +426,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } {// diff @@ -456,9 +438,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } } @@ -484,9 +465,8 @@ namespace TempFile file_right(filename_right, buf_right, strlen(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } {// diff @@ -498,9 +478,8 @@ namespace TempFile file_right(filename_right, buf_right, strlen(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } } @@ -527,9 +506,8 @@ namespace TempFile file_right(filename_right, buf_right, strlen(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::SAME, bc.CompareFiles(&pair.diffData)); } {// diff @@ -541,9 +519,8 @@ namespace TempFile file_right(filename_right, buf_right, strlen(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } } @@ -566,9 +543,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right) - 1); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } { @@ -576,9 +552,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right) ); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } { @@ -586,9 +561,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right)); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } { @@ -596,9 +570,8 @@ namespace TempFile file_right(filename_right, buf_right, WMCMPBUFF); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } { @@ -606,9 +579,8 @@ namespace TempFile file_right(filename_right, buf_right, sizeof(buf_right) - 1); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } { @@ -616,9 +588,8 @@ namespace TempFile file_right(filename_right, buf_right, WMCMPBUFF + 1); FilePair pair(filename_left, filename_right); - bc.SetFileData(2, pair.filedata); - EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(pair.location)); + EXPECT_EQ(DIFFCODE::TEXT|DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } } diff --git a/Testing/GoogleTest/UnitTests/UnitTests.vcxproj b/Testing/GoogleTest/UnitTests/UnitTests.vcxproj index 43708953f25..5caf85c0325 100644 --- a/Testing/GoogleTest/UnitTests/UnitTests.vcxproj +++ b/Testing/GoogleTest/UnitTests/UnitTests.vcxproj @@ -468,6 +468,11 @@ pch.h $(IntDir)$(TargetName)2.pch + + Use + pch.h + $(IntDir)$(TargetName)2.pch + Use pch.h @@ -483,12 +488,14 @@ pch.h $(IntDir)$(TargetName)2.pch + Use pch.h $(IntDir)$(TargetName)2.pch + Use pch.h @@ -562,6 +569,11 @@ pch.h $(IntDir)$(TargetName)2.pch + + Use + pch.h + $(IntDir)$(TargetName)2.pch + Create pch.h @@ -826,6 +838,7 @@ + @@ -866,4 +879,4 @@ - + \ No newline at end of file diff --git a/Testing/GoogleTest/UnitTests/UnitTests.vcxproj.filters b/Testing/GoogleTest/UnitTests/UnitTests.vcxproj.filters index fe4caceceb4..dbacaf604fa 100644 --- a/Testing/GoogleTest/UnitTests/UnitTests.vcxproj.filters +++ b/Testing/GoogleTest/UnitTests/UnitTests.vcxproj.filters @@ -285,15 +285,24 @@ Source Files - - Tests - Tests Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -443,5 +452,8 @@ Header Files + + Header Files + \ No newline at end of file