|
| 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 | + |
| 26 | +using namespace rapidjson; |
| 27 | + |
| 28 | +TEST(Platform, GetObject) { |
| 29 | + Document doc; |
| 30 | + doc.Parse(" { \"object\" : { \"pi\": 3.1416} } "); |
| 31 | + EXPECT_TRUE(doc.IsObject()); |
| 32 | + EXPECT_TRUE(doc.HasMember("object")); |
| 33 | + const Document::ValueType& o = doc["object"]; |
| 34 | + EXPECT_TRUE(o.IsObject()); |
| 35 | + auto sub = o.GetObject(); |
| 36 | + EXPECT_TRUE(sub.HasMember("pi")); |
| 37 | +} |
0 commit comments