|
||||
File indexing completed on 2025-01-30 10:02:52
0001 0002 // Copyright Catch2 Authors 0003 // Distributed under the Boost Software License, Version 1.0. 0004 // (See accompanying file LICENSE.txt or copy at 0005 // https://www.boost.org/LICENSE_1_0.txt) 0006 0007 // SPDX-License-Identifier: BSL-1.0 0008 #ifndef CATCH_REPORTER_COMMON_BASE_HPP_INCLUDED 0009 #define CATCH_REPORTER_COMMON_BASE_HPP_INCLUDED 0010 0011 #include <catch2/interfaces/catch_interfaces_reporter.hpp> 0012 0013 #include <map> 0014 #include <string> 0015 0016 namespace Catch { 0017 class ColourImpl; 0018 0019 /** 0020 * This is the base class for all reporters. 0021 * 0022 * If are writing a reporter, you must derive from this type, or one 0023 * of the helper reporter bases that are derived from this type. 0024 * 0025 * ReporterBase centralizes handling of various common tasks in reporters, 0026 * like storing the right stream for the reporters to write to, and 0027 * providing the default implementation of the different listing events. 0028 */ 0029 class ReporterBase : public IEventListener { 0030 protected: 0031 //! The stream wrapper as passed to us by outside code 0032 Detail::unique_ptr<IStream> m_wrapped_stream; 0033 //! Cached output stream from `m_wrapped_stream` to reduce 0034 //! number of indirect calls needed to write output. 0035 std::ostream& m_stream; 0036 //! Colour implementation this reporter was configured for 0037 Detail::unique_ptr<ColourImpl> m_colour; 0038 //! The custom reporter options user passed down to the reporter 0039 std::map<std::string, std::string> m_customOptions; 0040 0041 public: 0042 ReporterBase( ReporterConfig&& config ); 0043 ~ReporterBase() override; // = default; 0044 0045 /** 0046 * Provides a simple default listing of reporters. 0047 * 0048 * Should look roughly like the reporter listing in v2 and earlier 0049 * versions of Catch2. 0050 */ 0051 void listReporters( 0052 std::vector<ReporterDescription> const& descriptions ) override; 0053 /** 0054 * Provides a simple default listing of listeners 0055 * 0056 * Looks similarly to listing of reporters, but with listener type 0057 * instead of reporter name. 0058 */ 0059 void listListeners( 0060 std::vector<ListenerDescription> const& descriptions ) override; 0061 /** 0062 * Provides a simple default listing of tests. 0063 * 0064 * Should look roughly like the test listing in v2 and earlier versions 0065 * of Catch2. Especially supports low-verbosity listing that mimics the 0066 * old `--list-test-names-only` output. 0067 */ 0068 void listTests( std::vector<TestCaseHandle> const& tests ) override; 0069 /** 0070 * Provides a simple default listing of tags. 0071 * 0072 * Should look roughly like the tag listing in v2 and earlier versions 0073 * of Catch2. 0074 */ 0075 void listTags( std::vector<TagInfo> const& tags ) override; 0076 }; 0077 } // namespace Catch 0078 0079 #endif // CATCH_REPORTER_COMMON_BASE_HPP_INCLUDED
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |