Skip to content

Commit a94c5d2

Browse files
committed
Reproduced issue #421
1 parent 2e7d498 commit a94c5d2

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
include(gtest.cmake)
99

10-
file(GLOB TESTS_FILES *.hpp *.cpp)
10+
file(GLOB TESTS_FILES Issue421.cpp)
1111

1212
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
1313
add_compile_options(

test/Issue421.cpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright Benoit Blanchon 2014-2017
2+
// MIT License
3+
//
4+
// Arduino JSON library
5+
// https://github.com/bblanchon/ArduinoJson
6+
// If you like this project, please add a star!
7+
8+
#include <ArduinoJson.h>
9+
#include <gtest/gtest.h>
10+
11+
static void runTest(char* json) {
12+
DynamicJsonBuffer jsonBuffer;
13+
JsonObject& root = jsonBuffer.parseObject(json);
14+
ASSERT_TRUE(root.success());
15+
}
16+
17+
TEST(Issue421, NoComment) {
18+
char json[] =
19+
"{"
20+
" \"gateway\": {"
21+
" \"rgb_luminosity\": 25,"
22+
" \"rgb_led_type\": 4,"
23+
" \"oled\": 1"
24+
" }"
25+
"}";
26+
runTest(json);
27+
}
28+
29+
TEST(Issue421, CppStyleFullLine) {
30+
char json[] =
31+
"{"
32+
" \"gateway\": {"
33+
" \"rgb_luminosity\": 25,"
34+
"// 1=GRBW, 2=RGBW, 3=GRB, 4=RGB"
35+
" \"rgb_led_type\": 4,"
36+
" \"oled\": 1"
37+
" }"
38+
"}";
39+
runTest(json);
40+
}
41+
42+
TEST(Issue421, CStyleFullLine) {
43+
char json[] =
44+
"{"
45+
" \"gateway\": {"
46+
" \"rgb_luminosity\": 25,"
47+
"/* 1=GRBW, 2=RGBW, 3=GRB, 4=RGB */"
48+
" \"rgb_led_type\": 4,"
49+
" \"oled\": 1"
50+
" }"
51+
"}";
52+
runTest(json);
53+
}
54+
55+
TEST(Issue421, CppStyleTrailing) {
56+
char json[] =
57+
"{"
58+
" \"gateway\": {"
59+
" \"rgb_luminosity\": 25,"
60+
" \"rgb_led_type\": 4, // 1=GRBW, 2=RGBW, 3=GRB, 4=RGB"
61+
" \"oled\": 1"
62+
" }"
63+
"}";
64+
runTest(json);
65+
}
66+
67+
TEST(Issue421, CStyleTrailing) {
68+
char json[] =
69+
"{"
70+
" \"gateway\": {"
71+
" \"rgb_luminosity\": 25,"
72+
" \"rgb_led_type\": 4, /* 1=GRBW, 2=RGBW, 3=GRB, 4=RGB */"
73+
" \"oled\": 1"
74+
" }"
75+
"}";
76+
runTest(json);
77+
}

0 commit comments

Comments
 (0)