• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/tests/runner/test_stdout_reporter.cpp
1
/*
2
* (C) 2022 Jack Lloyd
3
* (C) 2022 René Meusel, Rohde & Schwarz Cybersecurity
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include "test_stdout_reporter.h"
9

10
#include <botan/version.h>
11

12
namespace Botan_Tests {
13

14
StdoutReporter::StdoutReporter(const Test_Options& opts, std::ostream& output_stream) :
1✔
15
      Reporter(opts), m_verbose(opts.verbose()), m_out(output_stream), m_tests_failed(0), m_tests_run(0) {}
1✔
16

17
void StdoutReporter::next_run() {
1✔
18
   if(current_test_run() == 1) {
1✔
19
      render_preamble();
1✔
20
   }
21
   clear();
2✔
22
}
1✔
23

24
void StdoutReporter::next_testsuite(const std::string& name) { m_out << name << ":\n"; }
311✔
25

26
void StdoutReporter::record(const std::string& name, const Test::Result& result) {
1,643✔
27
   m_out << result.result_string();
1,643✔
28
   m_tests_run += result.tests_run();
1,643✔
29

30
   const size_t failed = result.tests_failed();
1,643✔
31
   if(failed > 0) {
1,643✔
32
      m_tests_failed += failed;
×
33
      m_tests_failed_names.insert(name);
×
34
   }
35
}
1,643✔
36

37
void StdoutReporter::render() const { render_summary(); }
1✔
38

39
void StdoutReporter::clear() {
1✔
40
   m_tests_failed_names.clear();
1✔
41
   m_tests_failed = 0;
1✔
42
   m_tests_run = 0;
1✔
43
}
×
44

45
void StdoutReporter::render_preamble() const {
1✔
46
   m_out << "Testing " << Botan::version_string() << "\n";
1✔
47

48
   if(!properties().empty()) {
1✔
49
      m_out << "Properties:\n";
1✔
50

51
      for(const auto& prop : properties()) {
4✔
52
         m_out << "  " << prop.first << ": " << prop.second << "\n";
3✔
53
      }
54
   }
55
}
1✔
56

57
void StdoutReporter::render_summary() const {
1✔
58
   const auto total_ns = elapsed_time();
1✔
59

60
   if(total_test_runs() == 1)
1✔
61
      m_out << "Tests";
1✔
62
   else
63
      m_out << "Test run " << current_test_run() << "/" << total_test_runs();
×
64

65
   m_out << " complete ran " << m_tests_run << " tests in " << Botan_Tests::Test::format_time(total_ns) << " ";
1✔
66

67
   if(m_tests_failed > 0) {
1✔
68
      m_out << m_tests_failed << " tests failed (in ";
×
69

70
      bool first = true;
×
71
      for(const auto& test : m_tests_failed_names) {
×
72
         if(!first)
×
73
            m_out << " ";
×
74
         first = false;
×
75
         m_out << test;
×
76
      }
77

78
      m_out << ")";
×
79
   } else if(m_tests_run > 0) {
1✔
80
      m_out << "all tests ok";
1✔
81
   }
82

83
   m_out << "\n";
1✔
84
}
1✔
85

86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc