| 1 | /*++ |
| 2 | |
| 3 | Copyright (c) Microsoft. All rights reserved. |
| 4 | |
| 5 | Module Name: |
| 6 | |
| 7 | WSLCCLIOptionsParserUnitTests.cpp |
| 8 | |
| 9 | Abstract: |
| 10 | |
| 11 | This file contains unit tests for WSLC CLI driver option parsing. |
| 12 | --*/ |
| 13 | |
| 14 | #include "precomp.h" |
| 15 | #include "windows/Common.h" |
| 16 | #include "WSLCCLITestHelpers.h" |
| 17 | #include "ArgumentValidation.h" |
| 18 | |
| 19 | using namespace wsl::windows::wslc; |
| 20 | |
| 21 | namespace WSLCCLIOptionsParserUnitTests { |
| 22 | |
| 23 | class WSLCCLIOptionsParserUnitTests |
| 24 | { |
| 25 | WSLC_TEST_CLASS(WSLCCLIOptionsParserUnitTests) |
| 26 | |
| 27 | TEST_METHOD(WSLCCLIOptionsParser_ValidOptions) |
| 28 | { |
| 29 | std::vector<std::tuple<std::wstring, std::string, std::string>> validOptions = { |
| 30 | {L"SizeBytes=3145728", "SizeBytes", "3145728"}, |
| 31 | {L"ReadOnly", "ReadOnly", ""}, |
| 32 | {L"key=", "key", ""}, |
| 33 | {L"=value", "", "value"}, |
| 34 | {L"", "", ""}, |
| 35 | {L"key=a=b=c", "key", "a=b=c"}, |
| 36 | }; |
| 37 | |
| 38 | for (const auto& [input, expectedKey, expectedValue] : validOptions) |
| 39 | { |
| 40 | auto result = validation::ParseDriverOption(input); |
| 41 | VERIFY_ARE_EQUAL(expectedKey, result.first); |
| 42 | VERIFY_ARE_EQUAL(expectedValue, result.second); |
| 43 | } |
| 44 | } |
| 45 | }; |
| 46 | |
| 47 | } // namespace WSLCCLIOptionsParserUnitTests |