MCPcopy Create free account
hub / github.com/catboost/catboost / DoTestParse

Method DoTestParse

library/cpp/json/ut/json_reader_fast_ut.cpp:182–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180public:
181 template <bool accept>
182 void DoTestParse(TStringBuf json, ui32 amount, ...) {
183 using namespace NJson::NTest;
184 TEvents evs;
185 va_list vl;
186 va_start(vl, amount);
187 for (ui32 i = 0; i < amount; i++) {
188 ETestEvent e = (ETestEvent)va_arg(vl, int);
189
190 switch ((int)e) {
191 case E_NO_EVENT:
192 case E_DICT_OPEN:
193 case E_DICT_CLOSE:
194 case E_ARR_OPEN:
195 case E_ARR_CLOSE:
196 case E_NULL:
197 evs.push_back(e);
198 break;
199 case E_BOOL: {
200 bool v = va_arg(vl, int);
201 evs.push_back(TEvent((i64)v, E_BOOL));
202 break;
203 }
204 case E_INT: {
205 i64 i = va_arg(vl, int);
206 evs.push_back(TEvent(i, E_INT));
207 break;
208 }
209 case E_LONG_LONG: {
210 i64 i = va_arg(vl, long long);
211 evs.push_back(TEvent(i, E_INT));
212 break;
213 }
214 case E_FLT: {
215 double f = va_arg(vl, double);
216 evs.push_back(TEvent(f, E_FLT));
217 break;
218 }
219 case E_STR: {
220 const char* s = va_arg(vl, const char*);
221 evs.push_back(TEvent(TStringBuf(s), E_STR));
222 break;
223 }
224 case E_KEY:
225 case E_ERROR: {
226 const char* s = va_arg(vl, const char*);
227 evs.push_back(TEvent(TStringBuf(s), e));
228 break;
229 }
230 }
231 }
232 va_end(vl);
233
234 TTestHandler h;
235 const bool res = ReadJsonFast(json, &h);
236 UNIT_ASSERT_VALUES_EQUAL_C(res, accept, Sprintf("%s (%s)", ToString(json).data(), h.Events.back().Str.data()));
237 h.Assert(evs, ToString(json));
238 }
239

Callers

nothing calls this directly

Calls 7

SprintfFunction · 0.85
TEventClass · 0.70
ToStringFunction · 0.50
push_backMethod · 0.45
dataMethod · 0.45
backMethod · 0.45
AssertMethod · 0.45

Tested by

no test coverage detected