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

Function main

test/boost_json_encoder_test.cpp:230–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

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
serializeFunction · 0.70
check_diagnostic_infoFunction · 0.70
check_diagnostic_detailsFunction · 0.70
check_exceptionFunction · 0.70
serialize_toMethod · 0.45

Tested by

no test coverage detected