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

randombit / botan / 5123321399

30 May 2023 04:06PM UTC coverage: 92.213% (+0.004%) from 92.209%
5123321399

Pull #3558

github

web-flow
Merge dd72f7389 into 057bcbc35
Pull Request #3558: Add braces around all if/else statements

75602 of 81986 relevant lines covered (92.21%)

11859779.3 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

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

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

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

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

85
   m_out << "\n";
1✔
86
}
1✔
87

88
}  // namespace Botan_Tests
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