MCPcopy Create free account
hub / github.com/boostorg/leaf / main

Function main

test/nlohmann_json_encoder_test.cpp:231–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229#endif
230
231int main()
232{
233 {
234 nlohmann::ordered_json j;
235 leaf::try_handle_all(
236 []
237 {
238 return fail();
239 },
240 [&j](leaf::diagnostic_info const & di, my_error<1> const * e1)
241 {
242 BOOST_TEST(e1 != nullptr);
243 output_encoder e{j};
244 di.serialize_to(e);
245 }
246 );
247 std::cout << __LINE__ << " diagnostic_info JSON output:\n" << std::setw(2) << j << std::endl;
248 check_diagnostic_info(j, true);
249 }
250
251 {
252 nlohmann::ordered_json j;
253 leaf::try_handle_all(
254 []
255 {
256 return fail();
257 },
258 [&j](leaf::diagnostic_details const & dd, my_error<1> const * e1)
259 {
260 BOOST_TEST(e1 != nullptr);
261 output_encoder e{j};
262 dd.serialize_to(e);
263 }
264 );
265 std::cout << __LINE__ << " diagnostic_details JSON output:\n" << std::setw(2) << j << std::endl;
266 check_diagnostic_details(j, true);
267 }
268
269#ifndef BOOST_LEAF_NO_EXCEPTIONS
270 {
271 nlohmann::ordered_json j;
272 leaf::try_catch(
273 []
274 {
275 leaf_throw();
276 },
277 [&j](leaf::diagnostic_info const & di, my_error<1> const * e1)
278 {
279 BOOST_TEST(e1 != nullptr);
280 output_encoder e{j};
281 di.serialize_to(e);
282 }
283 );
284 std::cout << __LINE__ << " leaf_throw diagnostic_info JSON output:\n" << std::setw(2) << j << std::endl;
285 check_diagnostic_info(j, true);
286 check_exception(j);
287 }
288

Callers

nothing calls this directly

Calls 10

try_handle_allFunction · 0.85
try_catchFunction · 0.85
new_errorFunction · 0.85
try_capture_allFunction · 0.85
try_handle_someFunction · 0.85
report_errorsFunction · 0.85
check_diagnostic_infoFunction · 0.70
check_diagnostic_detailsFunction · 0.70
check_exceptionFunction · 0.70
serialize_toMethod · 0.45

Tested by

no test coverage detected