Skip to content

Commit ae1e279

Browse files
committed
tests for validating the embedded null
1 parent 338036f commit ae1e279

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/StoragePickersTests/PickerCommonTests.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ namespace Test::PickerCommonTests
2424
{
2525
class PickerCommonTests
2626
{
27+
private:
28+
static const wchar_t s_rawStringWithNull[];
29+
static const winrt::hstring s_embeddedNullString;
2730
public:
2831
BEGIN_TEST_CLASS(PickerCommonTests)
2932
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA") // MTA is required for ::Test::Bootstrap::SetupPackages()
@@ -392,7 +395,7 @@ namespace Test::PickerCommonTests
392395
// Arrange.
393396
auto test_cases = std::vector<std::tuple<winrt::hstring, bool>>{
394397
{L"validFileName.txt", true}, // Valid file name
395-
{L"in\0valid.txt", false}, // embedded null
398+
{s_embeddedNullString, false}, // embedded null
396399
{L"", true}, // Allow Empty string
397400
{L"validFileNameWithSpaces .txt", true},// Allow spaces
398401
{
@@ -435,7 +438,7 @@ namespace Test::PickerCommonTests
435438
{L"Valid", true}, // Valid commit button text
436439
{L"", true}, // Allow empty string
437440
{L"Valid Text", true}, // Allow spaces
438-
{L"Invalid\0Text", false}, // Embedded null is invalid
441+
{s_embeddedNullString, false}, // Embedded null is invalid
439442
};
440443

441444
TEST_METHOD(VerifyFolderPicker_ValidateCommitButtonText)
@@ -769,4 +772,8 @@ namespace Test::PickerCommonTests
769772
}
770773

771774
};
775+
776+
const wchar_t PickerCommonTests::s_rawStringWithNull[] = L"in\0valid.txt";
777+
const winrt::hstring PickerCommonTests::s_embeddedNullString{ std::wstring_view(s_rawStringWithNull, 12) };
778+
772779
}

0 commit comments

Comments
 (0)