catch_reporter_console.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Created by Phil on 5/12/2012.
  3. * Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
  4. *
  5. * Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED
  9. #define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED
  10. #include "catch_reporter_bases.hpp"
  11. #if defined(_MSC_VER)
  12. #pragma warning(push)
  13. #pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
  14. // Note that 4062 (not all labels are handled
  15. // and default is missing) is enabled
  16. #endif
  17. namespace Catch {
  18. // Fwd decls
  19. struct SummaryColumn;
  20. class TablePrinter;
  21. struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {
  22. std::unique_ptr<TablePrinter> m_tablePrinter;
  23. ConsoleReporter(ReporterConfig const& config);
  24. ~ConsoleReporter() override;
  25. static std::string getDescription();
  26. void noMatchingTestCases(std::string const& spec) override;
  27. void reportInvalidArguments(std::string const&arg) override;
  28. void assertionStarting(AssertionInfo const&) override;
  29. bool assertionEnded(AssertionStats const& _assertionStats) override;
  30. void sectionStarting(SectionInfo const& _sectionInfo) override;
  31. void sectionEnded(SectionStats const& _sectionStats) override;
  32. #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
  33. void benchmarkPreparing(std::string const& name) override;
  34. void benchmarkStarting(BenchmarkInfo const& info) override;
  35. void benchmarkEnded(BenchmarkStats<> const& stats) override;
  36. void benchmarkFailed(std::string const& error) override;
  37. #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
  38. void testCaseEnded(TestCaseStats const& _testCaseStats) override;
  39. void testGroupEnded(TestGroupStats const& _testGroupStats) override;
  40. void testRunEnded(TestRunStats const& _testRunStats) override;
  41. void testRunStarting(TestRunInfo const& _testRunInfo) override;
  42. private:
  43. void lazyPrint();
  44. void lazyPrintWithoutClosingBenchmarkTable();
  45. void lazyPrintRunInfo();
  46. void lazyPrintGroupInfo();
  47. void printTestCaseAndSectionHeader();
  48. void printClosedHeader(std::string const& _name);
  49. void printOpenHeader(std::string const& _name);
  50. // if string has a : in first line will set indent to follow it on
  51. // subsequent lines
  52. void printHeaderString(std::string const& _string, std::size_t indent = 0);
  53. void printTotals(Totals const& totals);
  54. void printSummaryRow(std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row);
  55. void printTotalsDivider(Totals const& totals);
  56. void printSummaryDivider();
  57. void printTestFilters();
  58. private:
  59. bool m_headerPrinted = false;
  60. };
  61. } // end namespace Catch
  62. #if defined(_MSC_VER)
  63. #pragma warning(pop)
  64. #endif
  65. #endif // TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED