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