[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / lldb / unittests / Utility / UriParserTest.cpp
blob4ce89ab8e06cae6dd89dcb18abfcacfaa22bd362
1 #include "lldb/Utility/UriParser.h"
2 #include "gtest/gtest.h"
4 using namespace lldb_private;
6 TEST(UriParserTest, Minimal) {
7 EXPECT_EQ((URI{"x", "y", llvm::None, "/"}), URI::Parse("x://y"));
10 TEST(UriParserTest, MinimalPort) {
11 EXPECT_EQ((URI{"x", "y", 1, "/"}), URI::Parse("x://y:1"));
14 TEST(UriParserTest, MinimalPath) {
15 EXPECT_EQ((URI{"x", "y", llvm::None, "/"}), URI::Parse("x://y/"));
18 TEST(UriParserTest, MinimalPortPath) {
19 EXPECT_EQ((URI{"x", "y", 1, "/"}), URI::Parse("x://y:1/"));
22 TEST(UriParserTest, LongPath) {
23 EXPECT_EQ((URI{"x", "y", llvm::None, "/abc/def/xyz"}),
24 URI::Parse("x://y/abc/def/xyz"));
27 TEST(UriParserTest, TypicalPortPathIPv4) {
28 EXPECT_EQ((URI{"connect", "192.168.100.132", 5432, "/"}),
29 URI::Parse("connect://192.168.100.132:5432/"));
32 TEST(UriParserTest, TypicalPortPathIPv6) {
33 EXPECT_EQ(
34 (URI{"connect", "2601:600:107f:db64:a42b:4faa:284:3082", 5432, "/"}),
35 URI::Parse("connect://[2601:600:107f:db64:a42b:4faa:284:3082]:5432/"));
38 TEST(UriParserTest, BracketedHostnamePort) {
39 EXPECT_EQ((URI{"connect", "192.168.100.132", 5432, "/"}),
40 URI::Parse("connect://[192.168.100.132]:5432/"));
43 TEST(UriParserTest, BracketedHostname) {
44 EXPECT_EQ((URI{"connect", "192.168.100.132", llvm::None, "/"}),
45 URI::Parse("connect://[192.168.100.132]"));
48 TEST(UriParserTest, BracketedHostnameWithPortIPv4) {
49 // Android device over IPv4: port is a part of the hostname.
50 EXPECT_EQ((URI{"connect", "192.168.100.132:1234", llvm::None, "/"}),
51 URI::Parse("connect://[192.168.100.132:1234]"));
54 TEST(UriParserTest, BracketedHostnameWithPortIPv6) {
55 // Android device over IPv6: port is a part of the hostname.
56 EXPECT_EQ((URI{"connect", "[2601:600:107f:db64:a42b:4faa:284]:1234",
57 llvm::None, "/"}),
58 URI::Parse("connect://[[2601:600:107f:db64:a42b:4faa:284]:1234]"));
61 TEST(UriParserTest, BracketedHostnameWithColon) {
62 EXPECT_EQ((URI{"connect", "192.168.100.132:5555", 1234, "/"}),
63 URI::Parse("connect://[192.168.100.132:5555]:1234"));
66 TEST(UriParserTest, SchemeHostSeparator) {
67 EXPECT_EQ(llvm::None, URI::Parse("x:/y"));
70 TEST(UriParserTest, SchemeHostSeparator2) {
71 EXPECT_EQ(llvm::None, URI::Parse("x:y"));
74 TEST(UriParserTest, SchemeHostSeparator3) {
75 EXPECT_EQ(llvm::None, URI::Parse("x//y"));
78 TEST(UriParserTest, SchemeHostSeparator4) {
79 EXPECT_EQ(llvm::None, URI::Parse("x/y"));
82 TEST(UriParserTest, BadPort) { EXPECT_EQ(llvm::None, URI::Parse("x://y:a/")); }
84 TEST(UriParserTest, BadPort2) {
85 EXPECT_EQ(llvm::None, URI::Parse("x://y:5432a/"));
88 TEST(UriParserTest, Empty) { EXPECT_EQ(llvm::None, URI::Parse("")); }
90 TEST(UriParserTest, PortOverflow) {
91 EXPECT_EQ(llvm::None,
92 URI::Parse("x://"
93 "y:"
94 "0123456789012345678901234567890123456789012345678"
95 "9012345678901234567890123456789012345678901234567"
96 "89/"));