GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 92.6% 25 / 0 / 27
Functions: 88.9% 8 / 0 / 9
Branches: 73.1% 19 / 0 / 26

src/utilities/core/StringStreamLogSink.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "StringStreamLogSink.hpp"
7 #include "StringStreamLogSink_Impl.hpp"
8
9 #include "Assert.hpp"
10
11 namespace openstudio {
12
13 namespace detail {
14
15
3/5
✓ Branch 2 taken 1167 times.
✓ Branch 5 taken 1167 times.
✓ Branch 8 taken 1167 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1167 StringStreamLogSink_Impl::StringStreamLogSink_Impl() : m_stringstream(new std::stringstream) {
16
1/1
✓ Branch 2 taken 1167 times.
1167 this->setStream(m_stringstream);
17
1/1
✓ Branch 1 taken 1167 times.
1167 this->enable();
18 1167 }
19
20 2334 StringStreamLogSink_Impl::~StringStreamLogSink_Impl() {
21 1167 this->disable();
22
23 // already called
24 //LogSink_Impl::~LogSink_Impl();
25 2334 }
26
27 467 std::string StringStreamLogSink_Impl::string() const {
28
1/1
✓ Branch 1 taken 467 times.
467 std::shared_lock l{m_mutex};
29
30
1/1
✓ Branch 2 taken 467 times.
934 return m_stringstream->str();
31 467 }
32
33 467 std::vector<LogMessage> StringStreamLogSink_Impl::logMessages() const {
34
2/2
✓ Branch 1 taken 467 times.
✓ Branch 4 taken 467 times.
467 return LogMessage::parseLogText(this->string());
35 }
36
37 1492 void StringStreamLogSink_Impl::resetStringStream() {
38
1/1
✓ Branch 1 taken 1492 times.
1492 std::unique_lock l{m_mutex};
39
40
2/2
✓ Branch 2 taken 1492 times.
✓ Branch 5 taken 1492 times.
2984 m_stringstream->str("");
41 1492 }
42
43 } // namespace detail
44
45
4/6
✓ Branch 1 taken 1167 times.
✓ Branch 4 taken 1167 times.
✓ Branch 7 taken 1167 times.
✓ Branch 11 taken 1167 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1167 StringStreamLogSink::StringStreamLogSink() : LogSink(boost::shared_ptr<detail::StringStreamLogSink_Impl>(new detail::StringStreamLogSink_Impl())) {
46
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 1167 times.
✗ Branch 5 not taken.
1167 OS_ASSERT(getImpl<detail::StringStreamLogSink_Impl>());
47 1167 }
48
49 ✗ std::string StringStreamLogSink::string() const {
50 ✗ return this->getImpl<detail::StringStreamLogSink_Impl>()->string();
51 }
52
53 467 std::vector<LogMessage> StringStreamLogSink::logMessages() const {
54
1/1
✓ Branch 3 taken 467 times.
467 return this->getImpl<detail::StringStreamLogSink_Impl>()->logMessages();
55 }
56
57 1492 void StringStreamLogSink::resetStringStream() {
58
1/1
✓ Branch 3 taken 1492 times.
1492 this->getImpl<detail::StringStreamLogSink_Impl>()->resetStringStream();
59 1492 }
60
61 } // namespace openstudio
62