@@ -29,6 +29,26 @@ RAPIDJSON_DIAG_OFF(4822) // local class member function does not have a body
29
29
30
30
using namespace rapidjson ;
31
31
32
+ TEST (Uri, DefaultConstructor) {
33
+ typedef GenericUri<Value> UriType;
34
+ UriType u;
35
+ EXPECT_TRUE (u.GetSchemeString () == 0 );
36
+ EXPECT_TRUE (u.GetAuthString () == 0 );
37
+ EXPECT_TRUE (u.GetPathString () == 0 );
38
+ EXPECT_TRUE (u.GetBaseString () == 0 );
39
+ EXPECT_TRUE (u.GetQueryString () == 0 );
40
+ EXPECT_TRUE (u.GetFragString () == 0 );
41
+ EXPECT_TRUE (u.GetString () == 0 );
42
+ EXPECT_TRUE (u.GetSchemeStringLength () == 0 );
43
+ EXPECT_TRUE (u.GetAuthStringLength () == 0 );
44
+ EXPECT_TRUE (u.GetPathStringLength () == 0 );
45
+ EXPECT_TRUE (u.GetBaseStringLength () == 0 );
46
+ EXPECT_TRUE (u.GetQueryStringLength () == 0 );
47
+ EXPECT_TRUE (u.GetFragStringLength () == 0 );
48
+ EXPECT_TRUE (u.GetStringLength () == 0 );
49
+ }
50
+
51
+
32
52
TEST (Uri, Parse) {
33
53
typedef GenericUri<Value, MemoryPoolAllocator<> > UriType;
34
54
MemoryPoolAllocator<CrtAllocator> allocator;
@@ -256,6 +276,27 @@ TEST(Uri, Parse_UTF16) {
256
276
EXPECT_TRUE (u.GetFragStringLength () == len);
257
277
}
258
278
279
+ TEST (Uri, CopyConstructor) {
280
+ typedef GenericUri<Value> UriType;
281
+ CrtAllocator allocator;
282
+
283
+ UriType u (" http://auth/path/xxx?query#frag" , &allocator);
284
+ UriType u2 (u);
285
+ EXPECT_TRUE (u == u2);
286
+ EXPECT_NE (&u.GetAllocator (), &u2.GetAllocator ());
287
+ }
288
+
289
+ TEST (Uri, Assignment) {
290
+ typedef GenericUri<Value> UriType;
291
+ CrtAllocator allocator;
292
+
293
+ UriType u (" http://auth/path/xxx?query#frag" , &allocator);
294
+ UriType u2;
295
+ u2 = u;
296
+ EXPECT_TRUE (u == u2);
297
+ EXPECT_NE (&u.GetAllocator (), &u2.GetAllocator ());
298
+ }
299
+
259
300
TEST (Uri, Resolve) {
260
301
typedef GenericUri<Value> UriType;
261
302
CrtAllocator allocator;
@@ -648,6 +689,15 @@ TEST(Uri, Match) {
648
689
EXPECT_FALSE (d.Match (a));
649
690
}
650
691
692
+ TEST (Uri, Issue1899) {
693
+ typedef GenericUri<Value, MemoryPoolAllocator<> > UriType;
694
+
695
+ UriType base = UriType (" http://auth/path/#frag" );
696
+ UriType ref = UriType (" http://newauth/newpath#newfrag" );
697
+ UriType res = ref.Resolve (base);
698
+ EXPECT_TRUE (StrCmp (res.GetString (), " http://newauth/newpath#newfrag" ) == 0 );
699
+ }
700
+
651
701
#if defined(_MSC_VER) || defined(__clang__)
652
702
RAPIDJSON_DIAG_POP
653
703
#endif
0 commit comments