2 // Copyright (c) 2013-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)
8 #ifndef BEAST_UNIT_TEST_RESULTS_HPP
9 #define BEAST_UNIT_TEST_RESULTS_HPP
11 #include <beast/unit_test/detail/const_container.hpp>
19 /** Holds a set of test condition outcomes in a testcase. */
23 /** Holds the result of evaluating one test condition. */
26 explicit test(bool pass_)
31 test(bool pass_, std::string const& reason_)
43 : public detail::const_container <std::vector <test>>
54 /** Returns the total number of test conditions. */
61 /** Returns the number of failed test conditions. */
68 /** Register a successful test condition. */
72 cont().emplace_back(true);
75 /** Register a failed test condition. */
77 fail(std::string const& reason = "")
80 cont().emplace_back(false, reason);
85 : public detail::const_container <std::vector <std::string>>
88 /** Insert a string into the log. */
90 insert(std::string const& s)
99 explicit case_results(std::string const& name = "")
104 /** Returns the name of this testcase. */
111 /** Memberspace for a container of test condition outcomes. */
114 /** Memberspace for a container of testcase log messages. */
118 //--------------------------------------------------------------------------
120 /** Holds the set of testcase results in a suite. */
122 : public detail::const_container <std::vector <case_results>>
126 std::size_t total_ = 0;
127 std::size_t failed_ = 0;
130 explicit suite_results(std::string const& name = "")
135 /** Returns the name of this suite. */
142 /** Returns the total number of test conditions. */
149 /** Returns the number of failures. */
156 /** Insert a set of testcase results. */
159 insert(case_results&& r)
161 cont().emplace_back(std::move(r));
162 total_ += r.tests.total();
163 failed_ += r.tests.failed();
167 insert(case_results const& r)
170 total_ += r.tests.total();
171 failed_ += r.tests.failed();
176 //------------------------------------------------------------------------------
178 // VFALCO TODO Make this a template class using scoped allocators
179 /** Holds the results of running a set of testsuites. */
181 : public detail::const_container <std::vector <suite_results>>
196 /** Returns the total number of test cases. */
203 /** Returns the total number of test conditions. */
210 /** Returns the number of failures. */
217 /** Insert a set of suite results. */
220 insert(suite_results&& r)
224 failed_ += r.failed();
225 cont().emplace_back(std::move(r));
229 insert(suite_results const& r)
233 failed_ += r.failed();