aboutsummaryrefslogtreecommitdiff
path: root/deps/inja/third_party/include/hayai/hayai_outputter.hpp
blob: 94055b2b1b50f3f0b17cc50e56bfcd406942bb11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef __HAYAI_OUTPUTTER
#define __HAYAI_OUTPUTTER
#include <iostream>
#include <cstddef>

#include "hayai_test_result.hpp"


namespace hayai
{
    /// Outputter.

    /// Abstract base class for outputters.
    class Outputter
    {
    public:
        /// Begin benchmarking.

        /// The total number of benchmarks registred is the sum of the two
        /// counts passed to the outputter.
        ///
        /// @param enabledCount Number of benchmarks to be executed.
        /// @param disabledCount Number of disabled benchmarks to be skipped.
        virtual void Begin(const std::size_t& enabledCount,
                           const std::size_t& disabledCount) = 0;


        /// End benchmarking.

        /// @param executedCount Number of benchmarks that have been executed.
        /// @param disabledCount Number of benchmarks that have been skipped
        /// because they are disabled.
        virtual void End(const std::size_t& executedCount,
                         const std::size_t& disabledCount) = 0;


        /// Begin benchmark test run.

        /// @param fixtureName Fixture name.
        /// @param testName Test name.
        /// @param parameters Test parameter description.
        /// @param runsCount Number of runs to be executed.
        /// @param iterationsCount Number of iterations per run.
        virtual void BeginTest(const std::string& fixtureName,
                               const std::string& testName,
                               const TestParametersDescriptor& parameters,
                               const std::size_t& runsCount,
                               const std::size_t& iterationsCount) = 0;


        /// End benchmark test run.

        /// @param fixtureName Fixture name.
        /// @param testName Test name.
        /// @param parameters Test parameter description.
        /// @param result Test result.
        virtual void EndTest(const std::string& fixtureName,
                             const std::string& testName,
                             const TestParametersDescriptor& parameters,
                             const TestResult& result) = 0;


        /// Skip disabled benchmark test run.

        /// @param fixtureName Fixture name.
        /// @param testName Test name.
        /// @param parameters Test parameter description.
        /// @param runsCount Number of runs to be executed.
        /// @param iterationsCount Number of iterations per run.
        virtual void SkipDisabledTest(const std::string& fixtureName,
                                      const std::string& testName,
                                      const TestParametersDescriptor&
                                          parameters,
                                      const std::size_t& runsCount,
                                      const std::size_t& iterationsCount) = 0;


        virtual ~Outputter()
        {

        }
    protected:
        /// Write a nicely formatted test name to a stream.
        static void WriteTestNameToStream(std::ostream& stream,
                                          const std::string& fixtureName,
                                          const std::string& testName,
                                          const TestParametersDescriptor&
                                              parameters)
        {
            stream << fixtureName << "." << testName;

            const std::vector<TestParameterDescriptor>& descs =
                parameters.Parameters();

            if (descs.empty())
                return;

            stream << "(";

            for (std::size_t i = 0; i < descs.size(); ++i)
            {
                if (i)
                    stream << ", ";

                const TestParameterDescriptor& desc = descs[i];
                stream << desc.Declaration << " = " << desc.Value;
            }

            stream << ")";
        }
    };
}
#endif