diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-06-03 17:49:33 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-06-07 19:44:36 -0500 |
commit | 266b097c0b0a13dd4934f55f61cad62ffcbb953d (patch) | |
tree | 21400e8e1f7a6a5ebbc1abaacb40c472fc0b9fbc /src/libs/dutil/test/DUtilUnitTest/EnvUtilTests.cpp | |
parent | 584213c5ffeca09b3fe24bd5e92f73fd057ac642 (diff) | |
download | wix-266b097c0b0a13dd4934f55f61cad62ffcbb953d.tar.gz wix-266b097c0b0a13dd4934f55f61cad62ffcbb953d.tar.bz2 wix-266b097c0b0a13dd4934f55f61cad62ffcbb953d.zip |
REG_EXPAND_SZ values are not necessarily a path.
Diffstat (limited to 'src/libs/dutil/test/DUtilUnitTest/EnvUtilTests.cpp')
-rw-r--r-- | src/libs/dutil/test/DUtilUnitTest/EnvUtilTests.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/libs/dutil/test/DUtilUnitTest/EnvUtilTests.cpp b/src/libs/dutil/test/DUtilUnitTest/EnvUtilTests.cpp new file mode 100644 index 00000000..76dfa774 --- /dev/null +++ b/src/libs/dutil/test/DUtilUnitTest/EnvUtilTests.cpp | |||
@@ -0,0 +1,50 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | #include "precomp.h" | ||
4 | |||
5 | using namespace System; | ||
6 | using namespace Xunit; | ||
7 | using namespace WixBuildTools::TestSupport; | ||
8 | |||
9 | namespace DutilTests | ||
10 | { | ||
11 | public ref class EnvUtil | ||
12 | { | ||
13 | public: | ||
14 | [Fact] | ||
15 | void EnvExpandEnvironmentStringsTest() | ||
16 | { | ||
17 | HRESULT hr = S_OK; | ||
18 | LPWSTR sczExpanded = NULL; | ||
19 | SIZE_T cchExpanded = 0; | ||
20 | LPCWSTR wzSimpleString = L"%USERPROFILE%"; | ||
21 | LPCWSTR wzMultipleString = L"%TEMP%;%PATH%"; | ||
22 | LPCWSTR wzLongMultipleString = L"%TEMP%;%PATH%;C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789"; | ||
23 | String^ expandedSimpleString = Environment::ExpandEnvironmentVariables(gcnew String(wzSimpleString)); | ||
24 | String^ expandedMultipleString = Environment::ExpandEnvironmentVariables(gcnew String(wzMultipleString)); | ||
25 | String^ expandedLongMultipleString = Environment::ExpandEnvironmentVariables(gcnew String(wzLongMultipleString)); | ||
26 | |||
27 | try | ||
28 | { | ||
29 | hr = EnvExpandEnvironmentStrings(wzSimpleString, &sczExpanded, &cchExpanded); | ||
30 | NativeAssert::Succeeded(hr, "Failed to expand simple string."); | ||
31 | WixAssert::StringEqual(expandedSimpleString, gcnew String(sczExpanded), false); | ||
32 | NativeAssert::Equal<SIZE_T>(expandedSimpleString->Length + 1, cchExpanded); | ||
33 | |||
34 | hr = EnvExpandEnvironmentStrings(wzMultipleString, &sczExpanded, &cchExpanded); | ||
35 | NativeAssert::Succeeded(hr, "Failed to expand multiple string."); | ||
36 | WixAssert::StringEqual(expandedMultipleString, gcnew String(sczExpanded), false); | ||
37 | NativeAssert::Equal<SIZE_T>(expandedMultipleString->Length + 1, cchExpanded); | ||
38 | |||
39 | hr = EnvExpandEnvironmentStrings(wzLongMultipleString, &sczExpanded, &cchExpanded); | ||
40 | NativeAssert::Succeeded(hr, "Failed to expand long multiple string."); | ||
41 | WixAssert::StringEqual(expandedLongMultipleString, gcnew String(sczExpanded), false); | ||
42 | NativeAssert::Equal<SIZE_T>(expandedLongMultipleString->Length + 1, cchExpanded); | ||
43 | } | ||
44 | finally | ||
45 | { | ||
46 | ReleaseStr(sczExpanded); | ||
47 | } | ||
48 | } | ||
49 | }; | ||
50 | } | ||