From 947de2ad9bef0d5a13a9848b9eee65f7553c8975 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Sun, 22 Dec 2024 21:33:37 +0900 Subject: [PATCH] WIP --- .../ByteCompare/ByteCompare_test.cpp | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Testing/GoogleTest/ByteCompare/ByteCompare_test.cpp b/Testing/GoogleTest/ByteCompare/ByteCompare_test.cpp index 47fe4fca603..2d259c6f062 100644 --- a/Testing/GoogleTest/ByteCompare/ByteCompare_test.cpp +++ b/Testing/GoogleTest/ByteCompare/ByteCompare_test.cpp @@ -437,6 +437,52 @@ namespace FilePair pair(filename_left, filename_right); + EXPECT_EQ(DIFFCODE::TEXT | DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); + } + } + for (int i = 0; i < 3; i++) + { + {// diff left: CRLF - right: no EOL + std::vector buf_left(WMCMPBUFF * 2 + 2 + i); + std::vector buf_right(WMCMPBUFF * 2 + i); + + memset(buf_left.data(), 'A', buf_left.size()); + memset(buf_right.data(), 'A', buf_right.size()); + + buf_left[10] = '\r'; + buf_left[11] = '\n'; + buf_right[10] = '\r'; + buf_right[11] = '\n'; + buf_left[buf_left.size() - 2] = '\r'; + buf_left[buf_left.size() - 1] = '\n'; + + TempFile file_left(filename_left, buf_left.data(), buf_left.size()); + TempFile file_right(filename_right, buf_right.data(), buf_right.size()); + + FilePair pair(filename_left, filename_right); + + EXPECT_EQ(DIFFCODE::TEXT | DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); + } + + {// diff left: no EOL - right: CRLF + std::vector buf_left(WMCMPBUFF * 2 + i); + std::vector buf_right(WMCMPBUFF * 2 + 2 + i); + + memset(buf_left.data(), 'A', buf_left.size()); + memset(buf_right.data(), 'A', buf_right.size()); + + buf_left[10] = '\r'; + buf_left[11] = '\n'; + buf_right[10] = '\r'; + buf_right[11] = '\n'; + buf_right[buf_right.size() - 2] = '\r'; + buf_right[buf_right.size() - 1] = '\n'; + + TempFile file_left(filename_left, buf_left.data(), buf_left.size()); + TempFile file_right(filename_right, buf_right.data(), buf_right.size()); + + FilePair pair(filename_left, filename_right); + EXPECT_EQ(DIFFCODE::TEXT | DIFFCODE::DIFF, bc.CompareFiles(&pair.diffData)); } }