mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-01 16:07:54 +08:00
34 lines
1.3 KiB
C++
34 lines
1.3 KiB
C++
|
#include "pch.h"
|
||
|
#include "lib\util.h"
|
||
|
|
||
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||
|
|
||
|
namespace FancyZonesUnitTests
|
||
|
{
|
||
|
TEST_CLASS(UtilUnitTests)
|
||
|
{
|
||
|
public:
|
||
|
TEST_METHOD(TestParseDeviceId)
|
||
|
{
|
||
|
// We're interested in the unique part between the first and last #'s
|
||
|
// Example input: \\?\DISPLAY#DELA026#5&10a58c63&0&UID16777488#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}
|
||
|
// Example output: DELA026#5&10a58c63&0&UID16777488
|
||
|
PCWSTR input = L"\\\\?\\DISPLAY#DELA026#5&10a58c63&0&UID16777488#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}";
|
||
|
wchar_t output[256]{};
|
||
|
ParseDeviceId(input, output, ARRAYSIZE(output));
|
||
|
Assert::AreEqual(0, wcscmp(output, L"DELA026#5&10a58c63&0&UID16777488"));
|
||
|
}
|
||
|
|
||
|
TEST_METHOD(TestParseInvalidDeviceId)
|
||
|
{
|
||
|
// We're interested in the unique part between the first and last #'s
|
||
|
// Example input: \\?\DISPLAY#DELA026#5&10a58c63&0&UID16777488#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}
|
||
|
// Example output: DELA026#5&10a58c63&0&UID16777488
|
||
|
PCWSTR input = L"AnInvalidDeviceId";
|
||
|
wchar_t output[256]{};
|
||
|
ParseDeviceId(input, output, ARRAYSIZE(output));
|
||
|
Assert::AreEqual(0, wcscmp(output, L"FallbackDevice"));
|
||
|
}
|
||
|
};
|
||
|
}
|