GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 59.1% 13 / 0 / 22
Functions: 55.6% 5 / 0 / 9
Branches: 57.1% 8 / 0 / 14

src/utilities/units/OSOptionalQuantity.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 "OSOptionalQuantity.hpp"
7 #include "Quantity.hpp"
8
9 #include "../core/Assert.hpp"
10
11 #include <cmath>
12
13 namespace openstudio {
14
15 ✗ OSOptionalQuantity::OSOptionalQuantity(const UnitSystem& sys) {
16 ✗ Quantity q(sys);
17 ✗ m_units = q.units();
18 ✗ }
19
20 ✗ OSOptionalQuantity::OSOptionalQuantity(const Unit& units) : m_units(units.clone()) {}
21
22
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OSOptionalQuantity::OSOptionalQuantity(const Quantity& quantity) : m_value(quantity.value()), m_units(quantity.units()) {}
23
24 ✗ OSOptionalQuantity::OSOptionalQuantity(const OSOptionalQuantity& oq) : m_value(oq.m_value), m_units(oq.units()) {}
25
26 1 OSOptionalQuantity& OSOptionalQuantity::operator=(const OSOptionalQuantity& oq) {
27
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (this == &oq) {
28 ✗ return *this;
29 }
30
31 1 m_value = oq.m_value;
32
1/1
✓ Branch 1 taken 1 time.
1 m_units = oq.units();
33 1 return *this;
34 }
35
36 ✗ bool OSOptionalQuantity::empty() const {
37 ✗ return !m_value;
38 }
39
40 2 bool OSOptionalQuantity::isSet() const {
41 2 return m_value.has_value();
42 }
43
44 2 Quantity OSOptionalQuantity::get() const {
45
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 OS_ASSERT(m_value);
46
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 return Quantity(*m_value, units());
47 }
48
49 3 Unit OSOptionalQuantity::units() const {
50 3 return m_units.clone();
51 }
52
53 } // namespace openstudio
54