From 266b097c0b0a13dd4934f55f61cad62ffcbb953d Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 3 Jun 2022 17:49:33 -0500 Subject: REG_EXPAND_SZ values are not necessarily a path. --- src/libs/dutil/test/DUtilUnitTest/RegUtilTest.cpp | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/libs/dutil/test/DUtilUnitTest/RegUtilTest.cpp') diff --git a/src/libs/dutil/test/DUtilUnitTest/RegUtilTest.cpp b/src/libs/dutil/test/DUtilUnitTest/RegUtilTest.cpp index 575e3238..9e97f5e0 100644 --- a/src/libs/dutil/test/DUtilUnitTest/RegUtilTest.cpp +++ b/src/libs/dutil/test/DUtilUnitTest/RegUtilTest.cpp @@ -207,6 +207,49 @@ namespace DutilTests } } + [Fact] + void RegUtilExpandLongStringValueTest() + { + this->ExpandLongStringValueTest(); + } + + [Fact] + void RegUtilExpandLongStringValueFallbackTest() + { + RegFunctionForceFallback(); + this->ExpandLongStringValueTest(); + } + + void ExpandLongStringValueTest() + { + HRESULT hr = S_OK; + LPWSTR sczValue = NULL; + LPCWSTR wzValue = L"%TEMP%;%PATH%;C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789"; + String^ expandedValue = Environment::ExpandEnvironmentVariables(gcnew String(wzValue)); + + try + { + this->CreateBaseKey(); + + hr = RegWriteExpandString(hkBase, L"ExpandString", wzValue); + NativeAssert::Succeeded(hr, "Failed to write expand string value."); + + hr = RegReadString(hkBase, L"ExpandString", &sczValue); + NativeAssert::Succeeded(hr, "Failed to read expand string value."); + WixAssert::StringEqual(expandedValue, gcnew String(sczValue), false); + + ReleaseNullStr(sczValue); + + hr = RegReadString(hkBase, L"ExpandString", &sczValue); + NativeAssert::Succeeded(hr, "Failed to read expand string value."); + WixAssert::StringEqual(expandedValue, gcnew String(sczValue), false); + } + finally + { + ReleaseStr(sczValue); + } + } + [Fact] void RegUtilNotExpandStringValueTest() { -- cgit v1.2.3-55-g6feb