Debian Codegraph @

3rdparty/catch2/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp

raw symbols SCIP
1
2 // Copyright Catch2 Authors
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE.txt or copy at
5 // https://www.boost.org/LICENSE_1_0.txt)
6
7 // SPDX-License-Identifier: BSL-1.0
8
9 /**\file
10 * Test that custom options are properly passed down to the reporter.
11 *
12 * We print out the arguments sorted by key, to have a stable expected
13 * output.
14 */
15
16 #include <catch2/catch_test_macros.hpp>
17 #include <catch2/reporters/catch_reporter_streaming_base.hpp>
18 #include <catch2/reporters/catch_reporter_registrars.hpp>
19
20 #include <algorithm>
21 #include <iostream>
22 #include <string>
23 #include <utility>
24 #include <vector>
25
26 class TestReporter : public Catch::StreamingReporterBase {
27 public:
28 TestReporter( Catch::ReporterConfig&& _config ):
29 StreamingReporterBase( std::move(_config) ) {
30 std::cout << "X29 - TestReporter constructed\n";
31 }
32
33 static std::string getDescription() {
34 return "X29 test reporter";
35 }
36
37 void testRunStarting( Catch::TestRunInfo const& ) override {
38 std::vector<std::pair<std::string, std::string>> options;
39 for ( auto const& kv : m_customOptions ) {
40 options.push_back( kv );
41 }
42 std::sort( options.begin(), options.end() );
43 bool first = true;
44 for ( auto const& kv : options ) {
45 if ( !first ) { std::cout << "::"; }
46 std::cout << kv.first << "=" << kv.second;
47 first = false;
48 }
49 std::cout << '\n';
50 }
51
52 ~TestReporter() override;
53 };
54
55 TestReporter::~TestReporter() = default;
56
57 CATCH_REGISTER_REPORTER( "test-reporter", TestReporter )
58
59 TEST_CASE( "Just a test case to run things" ) {}