summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/rapidjson/test/unittest/documenttest.cpp
diff options
context:
space:
mode:
author Miodrag Milanović <mmicko@gmail.com>2023-01-20 21:44:28 +0100
committer GitHub <noreply@github.com>2023-01-20 15:44:28 -0500
commitf6630310ebd116a9230976d4a47b894946f5aa6f (patch)
treebb1363ada5f0515564552c4dc3f6219c40108f01 /3rdparty/rapidjson/test/unittest/documenttest.cpp
parent898b04e457cdcb44a0798afd90d25bd36c748f44 (diff)
Update rapidjson to 012be8528783cdbf4b7a9e64f78bd8f056b97e24 (#10842)
Co-authored-by: Milo Yip <miloyip@gmail.com>
Diffstat (limited to '3rdparty/rapidjson/test/unittest/documenttest.cpp')
-rw-r--r--3rdparty/rapidjson/test/unittest/documenttest.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/3rdparty/rapidjson/test/unittest/documenttest.cpp b/3rdparty/rapidjson/test/unittest/documenttest.cpp
index ecd4b79bc2a..c3d1e484dcc 100644
--- a/3rdparty/rapidjson/test/unittest/documenttest.cpp
+++ b/3rdparty/rapidjson/test/unittest/documenttest.cpp
@@ -1,6 +1,6 @@
// Tencent is pleased to support the open source community by making RapidJSON available.
//
-// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
+// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
//
// Licensed under the MIT License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
@@ -128,8 +128,14 @@ TEST(Document, UnchangedOnParseError) {
Document doc;
doc.SetArray().PushBack(0, doc.GetAllocator());
+ ParseResult noError;
+ EXPECT_TRUE(noError);
+
ParseResult err = doc.Parse("{]");
EXPECT_TRUE(doc.HasParseError());
+ EXPECT_NE(err, noError);
+ EXPECT_NE(err.Code(), noError);
+ EXPECT_NE(noError, doc.GetParseError());
EXPECT_EQ(err.Code(), doc.GetParseError());
EXPECT_EQ(err.Offset(), doc.GetErrorOffset());
EXPECT_TRUE(doc.IsArray());
@@ -138,6 +144,9 @@ TEST(Document, UnchangedOnParseError) {
err = doc.Parse("{}");
EXPECT_FALSE(doc.HasParseError());
EXPECT_FALSE(err.IsError());
+ EXPECT_TRUE(err);
+ EXPECT_EQ(err, noError);
+ EXPECT_EQ(err.Code(), noError);
EXPECT_EQ(err.Code(), doc.GetParseError());
EXPECT_EQ(err.Offset(), doc.GetErrorOffset());
EXPECT_TRUE(doc.IsObject());
@@ -291,7 +300,14 @@ TEST(Document, Swap) {
o.SetObject().AddMember("a", 1, a);
// Swap between Document and Value
- // d1.Swap(o); // doesn't compile
+ d1.Swap(o);
+ EXPECT_TRUE(d1.IsObject());
+ EXPECT_TRUE(o.IsArray());
+
+ d1.Swap(o);
+ EXPECT_TRUE(d1.IsArray());
+ EXPECT_TRUE(o.IsObject());
+
o.Swap(d1);
EXPECT_TRUE(d1.IsObject());
EXPECT_TRUE(o.IsArray());
@@ -309,6 +325,8 @@ TEST(Document, Swap) {
EXPECT_TRUE(d1.IsNull());
// reset document, including allocator
+ // so clear o before so that it doesnt contain dangling elements
+ o.Clear();
Document().Swap(d2);
EXPECT_TRUE(d2.IsNull());
EXPECT_NE(&d2.GetAllocator(), &a);
@@ -488,15 +506,19 @@ TYPED_TEST(DocumentMove, MoveConstructorParseError) {
a.Parse("{ 4 = 4]");
ParseResult error(a.GetParseError(), a.GetErrorOffset());
EXPECT_TRUE(a.HasParseError());
+ EXPECT_NE(error, noError);
+ EXPECT_NE(error.Code(), noError);
EXPECT_NE(error.Code(), noError.Code());
EXPECT_NE(error.Offset(), noError.Offset());
D b(std::move(a));
EXPECT_FALSE(a.HasParseError());
EXPECT_TRUE(b.HasParseError());
+ EXPECT_EQ(a.GetParseError(), noError);
EXPECT_EQ(a.GetParseError(), noError.Code());
- EXPECT_EQ(b.GetParseError(), error.Code());
EXPECT_EQ(a.GetErrorOffset(), noError.Offset());
+ EXPECT_EQ(b.GetParseError(), error);
+ EXPECT_EQ(b.GetParseError(), error.Code());
EXPECT_EQ(b.GetErrorOffset(), error.Offset());
D c(std::move(b));