2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
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)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_UNIT_TEST_RESULTS_HPP
11 #define BOOST_BEAST_UNIT_TEST_RESULTS_HPP
13 #include <boost/beast/unit_test/detail/const_container.hpp>
22 /** Holds a set of test condition outcomes in a testcase. */
26 /** Holds the result of evaluating one test condition. */
29 explicit test(bool pass_)
34 test(bool pass_, std::string const& reason_)
46 : public detail::const_container <std::vector <test>>
57 /** Returns the total number of test conditions. */
64 /** Returns the number of failed test conditions. */
71 /** Register a successful test condition. */
75 cont().emplace_back(true);
78 /** Register a failed test condition. */
80 fail(std::string const& reason = "")
83 cont().emplace_back(false, reason);
88 : public detail::const_container <std::vector <std::string>>
91 /** Insert a string into the log. */
93 insert(std::string const& s)
102 explicit case_results(std::string const& name = "")
107 /** Returns the name of this testcase. */
114 /** Memberspace for a container of test condition outcomes. */
117 /** Memberspace for a container of testcase log messages. */
121 //--------------------------------------------------------------------------
123 /** Holds the set of testcase results in a suite. */
125 : public detail::const_container <std::vector <case_results>>
129 std::size_t total_ = 0;
130 std::size_t failed_ = 0;
133 explicit suite_results(std::string const& name = "")
138 /** Returns the name of this suite. */
145 /** Returns the total number of test conditions. */
152 /** Returns the number of failures. */
159 /** Insert a set of testcase results. */
162 insert(case_results&& r)
164 cont().emplace_back(std::move(r));
165 total_ += r.tests.total();
166 failed_ += r.tests.failed();
170 insert(case_results const& r)
173 total_ += r.tests.total();
174 failed_ += r.tests.failed();
179 //------------------------------------------------------------------------------
181 // VFALCO TODO Make this a template class using scoped allocators
182 /** Holds the results of running a set of testsuites. */
184 : public detail::const_container <std::vector <suite_results>>
199 /** Returns the total number of test cases. */
206 /** Returns the total number of test conditions. */
213 /** Returns the number of failures. */
220 /** Insert a set of suite results. */
223 insert(suite_results&& r)
227 failed_ += r.failed();
228 cont().emplace_back(std::move(r));
232 insert(suite_results const& r)
236 failed_ += r.failed();