Debian Codegraph @

LspCpp/third_party/rapidjson/test/unittest/platformtest.cpp

raw
1 // Tencent is pleased to support the open source community by making RapidJSON available.
2 //
3 // Copyright (C) 2021 THL A29 Limited, a Tencent company, and Milo Yip.
4 //
5 // Licensed under the MIT License (the "License"); you may not use this file except
6 // in compliance with the License. You may obtain a copy of the License at
7 //
8 // http://opensource.org/licenses/MIT
9 //
10 // Unless required by applicable law or agreed to in writing, software distributed
11 // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 // specific language governing permissions and limitations under the License.
14
15 #include "unittest.h"
16
17 // see https://github.com/Tencent/rapidjson/issues/1448
18 // including windows.h on purpose to provoke a compile time problem as GetObject is a
19 // macro that gets defined when windows.h is included
20 #ifdef _WIN32
21 #include <windows.h>
22 #endif
23
24 #include "rapidjson/document.h"
25 #undef GetObject
26
27 using namespace rapidjson;
28
29 TEST(Platform, GetObject) {
30 Document doc;
31 doc.Parse(" { \"object\" : { \"pi\": 3.1416} } ");
32 EXPECT_TRUE(doc.IsObject());
33 EXPECT_TRUE(doc.HasMember("object"));
34 const Document::ValueType& o = doc["object"];
35 EXPECT_TRUE(o.IsObject());
36 Value::ConstObject sub = o.GetObject();
37 EXPECT_TRUE(sub.HasMember("pi"));
38 Value::ConstObject sub2 = o.GetObj();
39 EXPECT_TRUE(sub2.HasMember("pi"));
40 }