Skip to content

Commit 3168d7c

Browse files
committed
add a test that provokes a compile time error on windows
1 parent 47b837e commit 3168d7c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

test/unittest/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ set(UNITTEST_SOURCES
1616
jsoncheckertest.cpp
1717
namespacetest.cpp
1818
pointertest.cpp
19+
platformtest.cpp
1920
prettywritertest.cpp
2021
ostreamwrappertest.cpp
2122
readertest.cpp

test/unittest/platformtest.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

Comments
 (0)