Skip to content

Commit

Permalink
explcitly fail on errors during parsing in benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
grisumbras committed Jul 10, 2024
1 parent 393a633 commit 96cb8e3
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ class boost_default_impl : public any_impl
p.finish(ec);
if(! ec)
auto jv = p.release();
else
throw system::system_error( ec );
}
return clock_type::now() - start;
}
Expand Down Expand Up @@ -343,6 +345,8 @@ class boost_default_impl : public any_impl

if(! ec)
auto jv = p.release();
else
throw system::system_error( ec );

fclose(f);
}
Expand Down Expand Up @@ -414,10 +418,12 @@ class boost_pool_impl : public any_impl
p.reset(&mr);
system::error_code ec;
p.write(s.data(), s.size(), ec);
if(! ec)
if( !ec.failed() )
p.finish(ec);
if(! ec)
if( !ec.failed() )
auto jv = p.release();
else
throw system::system_error( ec );
}
return clock_type::now() - start;
}
Expand Down Expand Up @@ -458,6 +464,8 @@ class boost_pool_impl : public any_impl

if(! ec)
auto jv = p.release();
else
throw system::system_error( ec );

fclose(f);
}
Expand Down Expand Up @@ -601,7 +609,8 @@ class boost_null_impl : public any_impl
p.reset();
system::error_code ec;
p.write(s.data(), s.size(), ec);
BOOST_ASSERT(! ec);
if( ec.failed() )
throw system::system_error( ec );
}
return clock_type::now() - start;
}
Expand Down Expand Up @@ -636,8 +645,10 @@ class boost_null_impl : public any_impl
break;
}

BOOST_ASSERT(! ec);
fclose(f);

if( ec.failed() )
throw system::system_error( ec );
}
return clock_type::now() - start;
}
Expand Down Expand Up @@ -683,6 +694,8 @@ class boost_simple_impl : public any_impl
monotonic_resource mr;
auto jv = json::parse(s, ec, &mr, popts);
(void)jv;
if( ec.failed() )
throw system::system_error( ec );
}
return clock_type::now() - start;
}
Expand All @@ -698,6 +711,8 @@ class boost_simple_impl : public any_impl
monotonic_resource mr;
auto jv = json::parse(is, ec, &mr, popts);
(void)jv;
if( ec.failed() )
throw system::system_error( ec );
}
return clock_type::now() - start;
}
Expand Down Expand Up @@ -749,6 +764,8 @@ class boost_operator_impl : public any_impl
value jv(&mr);
is.seekg(0);
is >> popts >> jv;
if( is.fail() )
throw system::system_error( std::io_errc::stream );
}
return clock_type::now() - start;
}
Expand All @@ -763,6 +780,8 @@ class boost_operator_impl : public any_impl
value jv(&mr);
std::ifstream is( fi.name, std::ios::in | std::ios::binary );
is >> popts >> jv;
if( is.fail() )
throw system::system_error( std::io_errc::stream );
}
return clock_type::now() - start;
}
Expand All @@ -781,6 +800,8 @@ class boost_operator_impl : public any_impl
std::ostringstream os;
os << jv;
out = os.str();
if( os.fail() )
throw system::system_error( std::io_errc::stream );
}
return clock_type::now() - start;
}
Expand Down

0 comments on commit 96cb8e3

Please sign in to comment.