]> git.proxmox.com Git - ceph.git/blame - ceph/src/Beast/extras/beast/unit_test/recorder.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / Beast / extras / beast / unit_test / recorder.hpp
CommitLineData
7c673cae
FG
1//
2// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef BEAST_UNIT_TEST_RECORDER_HPP
9#define BEAST_UNIT_TEST_RECORDER_HPP
10
11#include <beast/unit_test/results.hpp>
12#include <beast/unit_test/runner.hpp>
13
14namespace beast {
15namespace unit_test {
16
17/** A test runner that stores the results. */
18class recorder : public runner
19{
20private:
21 results m_results;
22 suite_results m_suite;
23 case_results m_case;
24
25public:
26 recorder() = default;
27 recorder(recorder const&) = default;
28 recorder& operator=(recorder const&) = default;
29
30 /** Returns a report with the results of all completed suites. */
31 results const&
32 report() const
33 {
34 return m_results;
35 }
36
37private:
38 virtual
39 void
40 on_suite_begin(suite_info const& info) override
41 {
42 m_suite = suite_results(info.full_name());
43 }
44
45 virtual
46 void
47 on_suite_end() override
48 {
49 m_results.insert(std::move(m_suite));
50 }
51
52 virtual
53 void
54 on_case_begin(std::string const& name) override
55 {
56 m_case = case_results(name);
57 }
58
59 virtual
60 void
61 on_case_end() override
62 {
63 if(m_case.tests.size() > 0)
64 m_suite.insert(std::move(m_case));
65 }
66
67 virtual
68 void
69 on_pass() override
70 {
71 m_case.tests.pass();
72 }
73
74 virtual
75 void
76 on_fail(std::string const& reason) override
77 {
78 m_case.tests.fail(reason);
79 }
80
81 virtual
82 void
83 on_log(std::string const& s) override
84 {
85 m_case.log.insert(s);
86 }
87};
88
89} // unit_test
90} // beast
91
92#endif