@@ -46,9 +46,9 @@ TEST(URITest, TestSetPath)
46
46
uri.SetPath (path);
47
47
EXPECT_EQ (path, uri.GetPath ());
48
48
49
- path = " path/to/resource/ " ;
49
+ path = " path/to/resource" ;
50
50
uri.SetPath (path);
51
- EXPECT_EQ (" /path/to/resource/ " , uri.GetPath ());
51
+ EXPECT_EQ (" /path/to/resource" , uri.GetPath ());
52
52
53
53
path = " //path/to//resource" ;
54
54
uri.SetPath (path);
@@ -62,6 +62,52 @@ TEST(URITest, TestSetPath)
62
62
EXPECT_EQ (path, uri.GetPath ());
63
63
}
64
64
65
+ TEST (URITest, TestAddPathSegments)
66
+ {
67
+ URI uri;
68
+
69
+ uri.AddPathSegment (" //" );
70
+ EXPECT_STREQ (" /" , uri.GetPath ().c_str ());
71
+ EXPECT_STREQ (" /" , uri.GetURLEncodedPath ().c_str ());
72
+
73
+ uri.SetPath (" " );
74
+ uri.AddPathSegment (" /path/" );
75
+ EXPECT_STREQ (" /path" , uri.GetPath ().c_str ());
76
+ EXPECT_STREQ (" /path" , uri.GetURLEncodedPath ().c_str ());
77
+
78
+ uri.SetPath (" " );
79
+ uri.AddPathSegment (" /path/" );
80
+ uri.AddPathSegment (" to" );
81
+ uri.AddPathSegment (" /some" );
82
+ uri.AddPathSegment (" resource/" );
83
+ EXPECT_STREQ (" /path/to/some/resource" , uri.GetPath ().c_str ());
84
+ EXPECT_STREQ (" /path/to/some/resource" , uri.GetURLEncodedPath ().c_str ());
85
+
86
+ uri.SetPath (" " );
87
+ uri.AddPathSegment (" /int" );
88
+ uri.AddPathSegment (10 );
89
+ uri.AddPathSegment (" float" );
90
+ uri.AddPathSegment (12.34 );
91
+ EXPECT_STREQ (" /int/10/float/12.34" , uri.GetPath ().c_str ());
92
+ EXPECT_STREQ (" /int/10/float/12.34" , uri.GetURLEncodedPath ().c_str ());
93
+
94
+ uri.SetPath (" " );
95
+ // There is no way to tell the differences between slashes in path segment and slashed as delimiters before encoding.
96
+ uri.AddPathSegment (" /path/segment/" );
97
+ EXPECT_STREQ (" /path/segment" , uri.GetPath ().c_str ());
98
+ EXPECT_STREQ (" /path%2Fsegment" , uri.GetURLEncodedPath ().c_str ());
99
+
100
+ uri.SetPath (" " );
101
+ uri.AddPathSegments (" //" );
102
+ EXPECT_STREQ (" /" , uri.GetPath ().c_str ());
103
+ EXPECT_STREQ (" /" , uri.GetURLEncodedPath ().c_str ());
104
+
105
+ uri.SetPath (" " );
106
+ uri.AddPathSegments (" //path/to//resource/" );
107
+ EXPECT_STREQ (" /path/to/resource" , uri.GetPath ().c_str ());
108
+ EXPECT_STREQ (" /path/to/resource" , uri.GetURLEncodedPath ().c_str ());
109
+ }
110
+
65
111
TEST (URITest, TestAddQueryStringParameters)
66
112
{
67
113
URI uri;
@@ -173,8 +219,8 @@ TEST(URITest, TestParse)
173
219
EXPECT_EQ (Scheme::HTTP, uriThatBrokeTheOtherDay.GetScheme ());
174
220
EXPECT_EQ (" sqs.us-east-1.amazonaws.com" , uriThatBrokeTheOtherDay.GetAuthority ());
175
221
EXPECT_EQ (80 , uriThatBrokeTheOtherDay.GetPort ());
176
- EXPECT_EQ (" /686094048/testQueueName/ " , uriThatBrokeTheOtherDay.GetPath ());
177
- EXPECT_EQ (" http://sqs.us-east-1.amazonaws.com/686094048/testQueueName/ " , uriThatBrokeTheOtherDay.GetURIString ());
222
+ EXPECT_EQ (" /686094048/testQueueName" , uriThatBrokeTheOtherDay.GetPath ());
223
+ EXPECT_EQ (" http://sqs.us-east-1.amazonaws.com/686094048/testQueueName" , uriThatBrokeTheOtherDay.GetURIString ());
178
224
}
179
225
180
226
TEST (URITest, TestParseWithColon)
@@ -232,7 +278,7 @@ TEST(URITest, TestGetURLEncodedPath)
232
278
TEST (URITest, TestGetRFC3986URLEncodedPath)
233
279
{
234
280
URI uri = " https://test.com/path/1234/" ;
235
- EXPECT_STREQ (" /path/1234/ " , URI::URLEncodePathRFC3986 (uri.GetPath ()).c_str ());
281
+ EXPECT_STREQ (" /path/1234" , URI::URLEncodePathRFC3986 (uri.GetPath ()).c_str ());
236
282
237
283
uri = " https://test.com/path/$omething" ;
238
284
EXPECT_STREQ (" /path/$omething" , URI::URLEncodePathRFC3986 (uri.GetPath ()).c_str ());
0 commit comments