FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-uri-parser/tests.cpp at master · lpcvoid/cpp-uri-parser · GitHub
lpcvoid
/
cpp-uri-parser
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
4
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-uri-parser
/
tests.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (67 loc) · 2.75 KB
Breadcrumbs
cpp-uri-parser
/
tests.cpp
Copy path
File metadata and controls
74 lines (67 loc) · 2.75 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#
define
DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#
include
"
doctest/doctest/doctest.h
"
#
include
"
URI.hpp
"
TEST_CASE
(
"
URI : only hostname
"
){
URI
uri
(
"
example.com
"
);
CHECK_EQ
(uri.
get_protocol
(), std::
nullopt
);
CHECK_NE
(uri.
get_authority
(), std::
nullopt
);
CHECK_NE
(uri.
get_host
(), std::
nullopt
);
CHECK_EQ
(uri.
get_host
().
value
(),
"
example.com
"
);
CHECK_EQ
(uri.
get_username
(), std::
nullopt
);
CHECK_EQ
(uri.
get_password
(), std::
nullopt
);
CHECK_EQ
(uri.
get_query
(), std::
nullopt
);
}
TEST_CASE
(
"
URI : only hostname and port
"
){
URI
uri
(
"
example.com:9000
"
);
CHECK_EQ
(uri.
get_protocol
(), std::
nullopt
);
CHECK_NE
(uri.
get_authority
(), std::
nullopt
);
CHECK_NE
(uri.
get_host
(), std::
nullopt
);
CHECK_EQ
(uri.
get_host
().
value
(),
"
example.com
"
);
CHECK_NE
(uri.
get_port
(), std::
nullopt
);
CHECK_EQ
(uri.
get_port
().
value
(),
9000
);
CHECK_EQ
(uri.
get_username
(), std::
nullopt
);
CHECK_EQ
(uri.
get_password
(), std::
nullopt
);
CHECK_EQ
(uri.
get_query
(), std::
nullopt
);
}
TEST_CASE
(
"
URI : complete with user, pass, port and query
"
){
URI
uri
(
"
https://user:pass@example.com:9000/query/query
"
);
CHECK_EQ
(uri.
get_result
(),
URI
::URIParsingResult::success);
CHECK_EQ
(uri.
get_protocol
(),
"
https
"
);
CHECK_NE
(uri.
get_authority
(), std::
nullopt
);
CHECK_NE
(uri.
get_port
(), std::
nullopt
);
CHECK_EQ
(uri.
get_port
().
value
(),
9000
);
CHECK_NE
(uri.
get_username
(), std::
nullopt
);
CHECK_EQ
(uri.
get_username
().
value
(),
"
user
"
);
CHECK_NE
(uri.
get_password
(), std::
nullopt
);
CHECK_EQ
(uri.
get_password
().
value
(),
"
pass
"
);
CHECK_NE
(uri.
get_host
(), std::
nullopt
);
CHECK_EQ
(uri.
get_host
().
value
(),
"
example.com
"
);
CHECK_EQ
(uri.
get_query
(),
"
/query/query
"
);
}
TEST_CASE
(
"
URI : host, port, query
"
){
URI
uri
(
"
https://example.com:9000/query/query
"
);
CHECK_EQ
(uri.
get_result
(),
URI
::URIParsingResult::success);
CHECK_EQ
(uri.
get_protocol
(),
"
https
"
);
CHECK_NE
(uri.
get_authority
(), std::
nullopt
);
CHECK_NE
(uri.
get_port
(), std::
nullopt
);
CHECK_EQ
(uri.
get_port
().
value
(),
9000
);
CHECK_NE
(uri.
get_host
(), std::
nullopt
);
CHECK_EQ
(uri.
get_host
().
value
(),
"
example.com
"
);
CHECK_EQ
(uri.
get_query
(),
"
/query/query
"
);
}
TEST_CASE
(
"
URI : protocol and host only
"
){
URI
uri
(
"
tcp://example.com
"
);
CHECK_EQ
(uri.
get_result
(),
URI
::URIParsingResult::success);
CHECK_EQ
(uri.
get_protocol
(),
"
tcp
"
);
CHECK_NE
(uri.
get_authority
(), std::
nullopt
);
CHECK_EQ
(uri.
get_port
(), std::
nullopt
);
CHECK_EQ
(uri.
get_username
(), std::
nullopt
);
CHECK_EQ
(uri.
get_password
(), std::
nullopt
);
CHECK_NE
(uri.
get_host
(), std::
nullopt
);
CHECK_EQ
(uri.
get_host
().
value
(),
"
example.com
"
);
CHECK_EQ
(uri.
get_query
(), std::
nullopt
);
}
TEST_CASE
(
"
URI : empty protocol
"
){
URI
uri
(
"
://example.com
"
);
CHECK_EQ
(uri.
get_result
(),
URI
::URIParsingResult::empty_protocol);
}
Back
|
FazBrowse Home
|
New Git URL