Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:25:00

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_UNIT_TEST_RECORDER_HPP
0011 #define BOOST_BEAST_UNIT_TEST_RECORDER_HPP
0012 
0013 #include <boost/beast/_experimental/unit_test/results.hpp>
0014 #include <boost/beast/_experimental/unit_test/runner.hpp>
0015 
0016 namespace boost {
0017 namespace beast {
0018 namespace unit_test {
0019 
0020 /** A test runner that stores the results. */
0021 class recorder : public runner
0022 {
0023     results m_results;
0024     suite_results m_suite;
0025     case_results m_case;
0026 
0027 public:
0028     recorder() = default;
0029 
0030     /** Returns a report with the results of all completed suites. */
0031     results const&
0032     report() const
0033     {
0034         return m_results;
0035     }
0036 
0037 private:
0038     virtual
0039     void
0040     on_suite_begin(suite_info const& info) override
0041     {
0042         m_suite = suite_results(info.full_name());
0043     }
0044 
0045     virtual
0046     void
0047     on_suite_end() override
0048     {
0049         m_results.insert(std::move(m_suite));
0050     }
0051 
0052     virtual
0053     void
0054     on_case_begin(std::string const& name) override
0055     {
0056         m_case = case_results(name);
0057     }
0058 
0059     virtual
0060     void
0061     on_case_end() override
0062     {
0063         if(m_case.tests.size() > 0)
0064             m_suite.insert(std::move(m_case));
0065     }
0066 
0067     virtual
0068     void
0069     on_pass() override
0070     {
0071         m_case.tests.pass();
0072     }
0073 
0074     virtual
0075     void
0076     on_fail(std::string const& reason) override
0077     {
0078         m_case.tests.fail(reason);
0079     }
0080 
0081     virtual
0082     void
0083     on_log(std::string const& s) override
0084     {
0085         m_case.log.insert(s);
0086     }
0087 };
0088 
0089 } // unit_test
0090 } // beast
0091 } // boost
0092 
0093 #endif