File indexing completed on 2025-01-18 09:29:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_TEST_IMPL_FAIL_COUNT_IPP
0011 #define BOOST_BEAST_TEST_IMPL_FAIL_COUNT_IPP
0012
0013 #include <boost/beast/_experimental/test/fail_count.hpp>
0014 #include <boost/throw_exception.hpp>
0015
0016 namespace boost {
0017 namespace beast {
0018 namespace test {
0019
0020 fail_count::
0021 fail_count(
0022 std::size_t n,
0023 error_code ev)
0024 : n_(n)
0025 , ec_(ev)
0026 {
0027 }
0028
0029 void
0030 fail_count::
0031 fail()
0032 {
0033 if(i_ < n_)
0034 ++i_;
0035 if(i_ == n_)
0036 BOOST_THROW_EXCEPTION(system_error{ec_});
0037 }
0038
0039 bool
0040 fail_count::
0041 fail(error_code& ec)
0042 {
0043 if(i_ < n_)
0044 ++i_;
0045 if(i_ == n_)
0046 {
0047 ec = ec_;
0048 return true;
0049 }
0050 ec = {};
0051 return false;
0052 }
0053
0054 }
0055 }
0056 }
0057
0058 #endif