| 134 | #endif |
| 135 | |
| 136 | void check_diagnostic_info(boost::json::value const & j, bool has_source_location) |
| 137 | { |
| 138 | BOOST_TEST(boost::json::value_to<int>(j.at("boost::leaf::error_id")) > 0); |
| 139 | |
| 140 | auto const & e1j = j.at("my_error<1>"); |
| 141 | BOOST_TEST_EQ(boost::json::value_to<int>(e1j.at("code")), 1); |
| 142 | BOOST_TEST_EQ(boost::json::value_to<std::string>(e1j.at("message")), "error one"); |
| 143 | |
| 144 | if( has_source_location ) |
| 145 | { |
| 146 | auto const & loc = j.at("boost::leaf::e_source_location"); |
| 147 | BOOST_TEST(!boost::json::value_to<std::string>(loc.at("file")).empty()); |
| 148 | BOOST_TEST(boost::json::value_to<int>(loc.at("line")) > 0); |
| 149 | BOOST_TEST(!boost::json::value_to<std::string>(loc.at("function")).empty()); |
| 150 | } |
| 151 | |
| 152 | BOOST_TEST(j.as_object().find("my_error<2>") == j.as_object().end()); |
| 153 | } |
| 154 | |
| 155 | void check_diagnostic_details(boost::json::value const & j, bool has_source_location) |
| 156 | { |