diff options
Diffstat (limited to 'src/libs/dutil/test/DUtilUnitTest/UriUtilTest.cpp')
-rw-r--r-- | src/libs/dutil/test/DUtilUnitTest/UriUtilTest.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/libs/dutil/test/DUtilUnitTest/UriUtilTest.cpp b/src/libs/dutil/test/DUtilUnitTest/UriUtilTest.cpp new file mode 100644 index 00000000..b3bf87a2 --- /dev/null +++ b/src/libs/dutil/test/DUtilUnitTest/UriUtilTest.cpp | |||
@@ -0,0 +1,98 @@ | |||
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 System::Text; | ||
7 | using namespace System::Collections::Generic; | ||
8 | using namespace Xunit; | ||
9 | |||
10 | namespace CfgTests | ||
11 | { | ||
12 | public ref class UriUtil | ||
13 | { | ||
14 | public: | ||
15 | [Fact] | ||
16 | void UriProtocolTest() | ||
17 | { | ||
18 | HRESULT hr = S_OK; | ||
19 | |||
20 | DutilInitialize(&DutilTestTraceError); | ||
21 | |||
22 | LPCWSTR uri = L"https://localhost/"; | ||
23 | URI_PROTOCOL uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
24 | hr = UriProtocol(uri, &uriProtocol); | ||
25 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
26 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_HTTPS, (int)uriProtocol); | ||
27 | |||
28 | uri = L"HTTPS://localhost/"; | ||
29 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
30 | hr = UriProtocol(uri, &uriProtocol); | ||
31 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
32 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_HTTPS, (int)uriProtocol); | ||
33 | |||
34 | uri = L"HtTpS://localhost/"; | ||
35 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
36 | hr = UriProtocol(uri, &uriProtocol); | ||
37 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
38 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_HTTPS, (int)uriProtocol); | ||
39 | |||
40 | uri = L"HTTP://localhost/"; | ||
41 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
42 | hr = UriProtocol(uri, &uriProtocol); | ||
43 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
44 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_HTTP, (int)uriProtocol); | ||
45 | |||
46 | uri = L"http://localhost/"; | ||
47 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
48 | hr = UriProtocol(uri, &uriProtocol); | ||
49 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
50 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_HTTP, (int)uriProtocol); | ||
51 | |||
52 | uri = L"HtTp://localhost/"; | ||
53 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
54 | hr = UriProtocol(uri, &uriProtocol); | ||
55 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
56 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_HTTP, (int)uriProtocol); | ||
57 | |||
58 | uri = L"file://localhost/"; | ||
59 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
60 | hr = UriProtocol(uri, &uriProtocol); | ||
61 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
62 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_FILE, (int)uriProtocol); | ||
63 | |||
64 | uri = L"FILE://localhost/"; | ||
65 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
66 | hr = UriProtocol(uri, &uriProtocol); | ||
67 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
68 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_FILE, (int)uriProtocol); | ||
69 | |||
70 | uri = L"FiLe://localhost/"; | ||
71 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
72 | hr = UriProtocol(uri, &uriProtocol); | ||
73 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
74 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_FILE, (int)uriProtocol); | ||
75 | |||
76 | uri = L"FTP://localhost/"; | ||
77 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
78 | hr = UriProtocol(uri, &uriProtocol); | ||
79 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
80 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_FTP, (int)uriProtocol); | ||
81 | |||
82 | uri = L"ftp://localhost/"; | ||
83 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
84 | hr = UriProtocol(uri, &uriProtocol); | ||
85 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
86 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_FTP, (int)uriProtocol); | ||
87 | |||
88 | uri = L"FtP://localhost/"; | ||
89 | uriProtocol = URI_PROTOCOL::URI_PROTOCOL_UNKNOWN; | ||
90 | hr = UriProtocol(uri, &uriProtocol); | ||
91 | ExitOnFailure(hr, "Failed to determine UriProtocol"); | ||
92 | Assert::Equal((int)URI_PROTOCOL::URI_PROTOCOL_FTP, (int)uriProtocol); | ||
93 | |||
94 | LExit: | ||
95 | DutilUninitialize(); | ||
96 | } | ||
97 | }; | ||
98 | } | ||