forked from rluba/jaison
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtests.jai
More file actions
254 lines (221 loc) · 26 KB
/
tests.jai
File metadata and controls
254 lines (221 loc) · 26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// Some tests to make sure we don’t leak stuff, even in complex scenarios.
#import "Basic"()(MEMORY_DEBUGGER = true);
#load "module.jai";
JSON :: #string END
{
"errors": true,
"items": [
{
"index": {
"_id": "somesensitiveid",
"_index": "documents",
"_primary_term": 1,
"_seq_no": 35230,
"_shards": {
"failed": 0,
"successful": 1,
"total": 2
},
"_type": "_doc",
"_version": 1,
"result": "created",
"status": 201
}
},
{
"index": {
"_id": "somesensitiveid2",
"_index": "documents",
"_type": "_doc",
"error": {
"caused_by": {
"reason": "Invalid UTF-8 middle byte 0x6e\n at [Source: (org.elasticsearch.common.bytes.AbstractBytesReference$MarkSupportingStreamInputWrapper); line: 1, column: 119]",
"type": "json_parse_exception"
},
"reason": "failed to parse field [path] of type [text] in document with id 'somesensitiveid2'. Preview of field's value: ''",
"type": "mapper_parsing_exception"
},
"status": 400
}
}
],
"took": 200
}
END
JSON2 :: #string END
{"took":200,"errors":true,"items":[{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35230,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35231,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35232,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35233,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35234,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35235,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35236,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35237,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35238,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35239,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35240,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35241,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35242,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35243,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35244,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35245,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35246,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35247,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35248,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35249,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35250,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35251,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35252,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35253,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35254,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35255,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35256,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35257,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35258,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35259,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35260,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35261,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35262,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35263,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35264,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35265,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35266,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35267,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35268,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35269,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35270,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35271,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35272,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35273,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35274,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35275,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35276,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35277,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35278,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35279,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35280,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35281,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35282,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35283,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35284,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35285,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35286,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35287,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35288,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35289,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35290,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35291,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35292,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35293,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35294,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35295,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35296,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35297,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35298,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35299,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35300,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35301,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","status":400,"error":{"type":"mapper_parsing_exception","reason":"failed to parse field [path] of type [text] in document with id '_daten_akten_m_30500-30999_m30540_m30540-GT_files_OFA_-_Brand_registration_Advertisements_DE_June_Elektroh_ndler_SV_4720_pdf'. Preview of field's value: ''","caused_by":{"type":"json_parse_exception","reason":"Invalid UTF-8 middle byte 0x6e\n at [Source: (org.elasticsearch.common.bytes.AbstractBytesReference$MarkSupportingStreamInputWrapper); line: 1, column: 119]"}}}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35302,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35303,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35304,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35305,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35306,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35307,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35308,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35309,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35310,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35311,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35312,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35313,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35314,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35315,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35316,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35317,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35318,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35319,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35320,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35321,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35322,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35323,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35324,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35325,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35326,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35327,"_primary_term":1,"status":201}},{"index":{"_index":"documents","_type":"_doc","_id":"somesensitiveid","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":35328,"_primary_term":1,"status":201}}]}
END
Message :: struct {
message: string;
values: [2] int;
}
MESSAGE_JSON :: #string END
{
"message" : "hello sailor",
"values": [1, 2]
}
END
Index_Result :: struct {
took: int;
errors: bool;
items: [..] Item;
Item :: struct {
index: Index;
}
Index :: struct {
_id: string;
_index: string;
_type: string;
_version: int;
_shards: Shard_Info;
_seq_no: int;
_primary_term: int;
result: string;
status: int;
error: Error;
}
Error :: struct {
caused_by: *Error;
reason: string;
type: string;
}
Shard_Info :: struct {
total: int;
successful: int;
failed: int;
}
}
free_result :: (result: Index_Result) {
for result.items {
free_error(it.index.error);
free(it.index._id);
free(it.index._index);
free(it.index._type);
free(it.index.result);
}
array_free(result.items);
}
free_error :: (error: Index_Result.Error) {
if error.caused_by {
free_error(error.caused_by);
free(error.caused_by);
}
free(error.reason);
free(error.type);
}
main :: () {
// Parser error tests
{
success, result := json_parse_string("");
assert(!success);
success, result = json_parse_string("[");
assert(!success);
json_free(result);
success, result = json_parse_string("[\"missing_close_bracket\"");
assert(!success);
json_free(result);
success, result = json_parse_string("\"");
assert(!success);
json_free(result);
success, result = json_parse_string("\"missing_close_quote");
assert(!success);
json_free(result);
success, result = json_parse_string("{");
assert(!success);
json_free(result);
success, result = json_parse_string("{\"missing_close_paren\"");
assert(!success);
json_free(result);
}
log("Report after parse errors 1:");
report_memory_leaks();
{
success, array_result := json_parse_string("[", []string);
assert(!success);
for array_result free(it);
array_free(array_result);
success, array_result = json_parse_string("[\"missing_close_bracket\"", []string);
assert(!success);
for array_result free(it);
array_free(array_result);
success, array_result = json_parse_string("[\"missing_item_and_bracket\",", []string);
assert(!success);
for array_result free(it);
array_free(array_result);
success, array_result = json_parse_string("[\"missing_item\",]", []string);
assert(!success);
for array_result free(it);
array_free(array_result);
}
log("Report after parse errors 2:");
report_memory_leaks();
{
success, string_result := json_parse_string("\"", string);
assert(!success);
free(string_result);
success, string_result = json_parse_string("\"missing_close_quote", string);
assert(!success);
free(string_result);
}
log("Report after parse errors 3:");
report_memory_leaks();
{
Result :: struct {
value: string;
}
success, object_result := json_parse_string("", Result);
assert(!success);
free(object_result.value);
success, object_result = json_parse_string("{", Result);
assert(!success);
free(object_result.value);
success, object_result = json_parse_string("{\"value:\": \"missing_close_paren\"", Result);
assert(!success);
free(object_result.value);
success, object_result = json_parse_string("{\"value:\": \"missing_item_and_paren\",", Result);
assert(!success);
free(object_result.value);
success, object_result = json_parse_string("{\"value:\": \"missing_item\",}", Result);
assert(!success);
free(object_result.value);
success, object_result = json_parse_string("{\"value:\":", Result);
assert(!success);
free(object_result.value);
success, object_result = json_parse_string("{\"value:\":}", Result);
assert(!success);
free(object_result.value);
success, object_result = json_parse_string("{\"value:\":,}", Result);
assert(!success);
free(object_result.value);
}
log("Report after parse errors 4:");
report_memory_leaks();
{
success, result := json_parse_string(JSON, Index_Result);
defer free_result(result);
log("Success: % result: %\n", success, result);
}
{
success, result := json_parse_string(JSON2, Index_Result);
defer free_result(result);
log("Success: % result: %\n", success, result);
}
log("Report after complex stuff:");
report_memory_leaks();
for 0..200 {
success, result := json_parse_string(JSON);
defer json_free(result);
assert(success, "Parse % failed", it);
reset_temporary_storage();
}
log("Report after loop 1:");
report_memory_leaks();
for 0..100 {
success, result := json_parse_string(MESSAGE_JSON, Message);
defer free(result.message);
assert(success, "Parse % failed", it);
reset_temporary_storage();
}
log("Report after messages:");
report_memory_leaks();
}