Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSteve Hanson <smh@uk.ibm.com>2021-06-14 13:35:00 +0300
committerSteve Hanson <smh@uk.ibm.com>2021-06-14 13:35:00 +0300
commita21cf9f7b800c86f75d4f0ff9f9de0a69ebb14af (patch)
tree5af9a3060fcb87ae763ce03dd6e4adb17bb26883 /test
parent12b88efa6f35ae820bab05a60b7ca5d73113e41c (diff)
equiv fix for issue 1899
Diffstat (limited to 'test')
-rw-r--r--test/unittest/uritest.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/unittest/uritest.cpp b/test/unittest/uritest.cpp
index 7fa7b93c..6cfa27d6 100644
--- a/test/unittest/uritest.cpp
+++ b/test/unittest/uritest.cpp
@@ -29,6 +29,26 @@ RAPIDJSON_DIAG_OFF(4822) // local class member function does not have a body
using namespace rapidjson;
+TEST(Uri, DefaultConstructor) {
+ typedef GenericUri<Value> UriType;
+ UriType u;
+ EXPECT_TRUE(u.GetSchemeString() == 0);
+ EXPECT_TRUE(u.GetAuthString() == 0);
+ EXPECT_TRUE(u.GetPathString() == 0);
+ EXPECT_TRUE(u.GetBaseString() == 0);
+ EXPECT_TRUE(u.GetQueryString() == 0);
+ EXPECT_TRUE(u.GetFragString() == 0);
+ EXPECT_TRUE(u.GetString() == 0);
+ EXPECT_TRUE(u.GetSchemeStringLength() == 0);
+ EXPECT_TRUE(u.GetAuthStringLength() == 0);
+ EXPECT_TRUE(u.GetPathStringLength() == 0);
+ EXPECT_TRUE(u.GetBaseStringLength() == 0);
+ EXPECT_TRUE(u.GetQueryStringLength() == 0);
+ EXPECT_TRUE(u.GetFragStringLength() == 0);
+ EXPECT_TRUE(u.GetStringLength() == 0);
+}
+
+
TEST(Uri, Parse) {
typedef GenericUri<Value, MemoryPoolAllocator<> > UriType;
MemoryPoolAllocator<CrtAllocator> allocator;
@@ -256,6 +276,27 @@ TEST(Uri, Parse_UTF16) {
EXPECT_TRUE(u.GetFragStringLength() == len);
}
+TEST(Uri, CopyConstructor) {
+ typedef GenericUri<Value> UriType;
+ CrtAllocator allocator;
+
+ UriType u("http://auth/path/xxx?query#frag", &allocator);
+ UriType u2(u);
+ EXPECT_TRUE(u == u2);
+ EXPECT_NE(&u.GetAllocator(), &u2.GetAllocator());
+}
+
+TEST(Uri, Assignment) {
+ typedef GenericUri<Value> UriType;
+ CrtAllocator allocator;
+
+ UriType u("http://auth/path/xxx?query#frag", &allocator);
+ UriType u2;
+ u2 = u;
+ EXPECT_TRUE(u == u2);
+ EXPECT_NE(&u.GetAllocator(), &u2.GetAllocator());
+}
+
TEST(Uri, Resolve) {
typedef GenericUri<Value> UriType;
CrtAllocator allocator;
@@ -648,6 +689,15 @@ TEST(Uri, Match) {
EXPECT_FALSE(d.Match(a));
}
+TEST(Uri, Issue1899) {
+ typedef GenericUri<Value, MemoryPoolAllocator<> > UriType;
+
+ UriType base = UriType("http://auth/path/#frag");
+ UriType ref = UriType("http://newauth/newpath#newfrag");
+ UriType res = ref.Resolve(base);
+ EXPECT_TRUE(StrCmp(res.GetString(), "http://newauth/newpath#newfrag") == 0);
+}
+
#if defined(_MSC_VER) || defined(__clang__)
RAPIDJSON_DIAG_POP
#endif