summaryrefslogtreecommitdiff
path: root/src/test/DUtilUnitTest/FileUtilTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/DUtilUnitTest/FileUtilTest.cpp')
-rw-r--r--src/test/DUtilUnitTest/FileUtilTest.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/test/DUtilUnitTest/FileUtilTest.cpp b/src/test/DUtilUnitTest/FileUtilTest.cpp
index 0087a1d5..ac071ef2 100644
--- a/src/test/DUtilUnitTest/FileUtilTest.cpp
+++ b/src/test/DUtilUnitTest/FileUtilTest.cpp
@@ -50,7 +50,7 @@ namespace DutilTests
50 } 50 }
51 51
52 private: 52 private:
53 void TestFile(LPWSTR wzDir, LPCWSTR wzTempDir, LPWSTR wzFileName, DWORD dwExpectedStringLength, FILE_ENCODING feExpectedEncoding) 53 void TestFile(LPWSTR wzDir, LPCWSTR wzTempDir, LPWSTR wzFileName, size_t cbExpectedStringLength, FILE_ENCODING feExpectedEncoding)
54 { 54 {
55 HRESULT hr = S_OK; 55 HRESULT hr = S_OK;
56 LPWSTR sczFullPath = NULL; 56 LPWSTR sczFullPath = NULL;
@@ -61,6 +61,7 @@ namespace DutilTests
61 DWORD cbFile1 = 0; 61 DWORD cbFile1 = 0;
62 BYTE *pbFile2 = NULL; 62 BYTE *pbFile2 = NULL;
63 DWORD cbFile2 = 0; 63 DWORD cbFile2 = 0;
64 size_t cbActualStringLength = 0;
64 65
65 try 66 try
66 { 67 {
@@ -77,10 +78,13 @@ namespace DutilTests
77 NativeAssert::Succeeded(hr, "FileToString() returned NULL for file: {0}", sczFullPath); 78 NativeAssert::Succeeded(hr, "FileToString() returned NULL for file: {0}", sczFullPath);
78 } 79 }
79 80
80 if ((DWORD)lstrlenW(sczContents) != dwExpectedStringLength) 81 hr = ::StringCchLengthW(sczContents, STRSAFE_MAX_CCH, &cbActualStringLength);
82 NativeAssert::Succeeded(hr, "Failed to get length of text from file: {0}", sczFullPath);
83
84 if (cbActualStringLength != cbExpectedStringLength)
81 { 85 {
82 hr = E_FAIL; 86 hr = E_FAIL;
83 ExitOnFailure(hr, "FileToString() returned wrong size for file: %ls (expected size %u, found size %u)", sczFullPath, dwExpectedStringLength, lstrlenW(sczContents)); 87 ExitOnFailure(hr, "FileToString() returned wrong size for file: %ls (expected size %Iu, found size %Iu)", sczFullPath, cbExpectedStringLength, cbActualStringLength);
84 } 88 }
85 89
86 if (feEncodingFound != feExpectedEncoding) 90 if (feEncodingFound != feExpectedEncoding)