GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 87.8% 36 / 0 / 41
Functions: 91.7% 11 / 0 / 12
Branches: 69.2% 27 / 0 / 39

src/utilities/units/TemperatureUnit.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 "TemperatureUnit.hpp"
7 #include "TemperatureUnit_Impl.hpp"
8
9 namespace openstudio {
10 namespace detail {
11
12 2997 bool TemperatureUnit_Impl::isAbsolute() const {
13 2997 return m_absolute;
14 }
15
16 13 void TemperatureUnit_Impl::setAsAbsolute() {
17 13 m_absolute = true;
18 13 }
19
20 47 void TemperatureUnit_Impl::setAsRelative() {
21 47 m_absolute = false;
22 47 }
23
24 1439 bool TemperatureUnit_Impl::operator==(const Unit& rUnit) const {
25 1439 bool result = Unit_Impl::operator==(rUnit);
26
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 7 times.
1439 if (result) {
27
2/3
✓ Branch 1 taken 1432 times.
✓ Branch 4 taken 1432 times.
✗ Branch 5 not taken.
2864 if (rUnit.optionalCast<TemperatureUnit>()) {
28
2/2
✓ Branch 2 taken 1432 times.
✓ Branch 5 taken 1432 times.
1432 result = (this->isAbsolute() == rUnit.cast<TemperatureUnit>().isAbsolute());
29 } else {
30 ✗ result = false;
31 }
32 }
33 1439 return result;
34 }
35
36 11 void TemperatureUnit_Impl::operator*=(const Unit& rUnit) {
37
1/1
✓ Branch 1 taken 11 times.
11 Unit_Impl::operator*=(rUnit);
38
1/1
✓ Branch 1 taken 11 times.
11 OptionalTemperatureUnit rTUnit = rUnit.optionalCast<TemperatureUnit>();
39
9/11
✓ Branch 1 taken 11 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 9 times.
13 if (!isAbsolute() && rTUnit && rTUnit->isAbsolute()) {
40
1/1
✓ Branch 1 taken 2 times.
2 setAsAbsolute();
41 }
42 11 }
43
44 7 void TemperatureUnit_Impl::operator/=(const Unit& rUnit) {
45
1/1
✓ Branch 1 taken 7 times.
7 Unit_Impl::operator/=(rUnit);
46
1/1
✓ Branch 1 taken 7 times.
7 OptionalTemperatureUnit rTUnit = rUnit.optionalCast<TemperatureUnit>();
47
3/11
✓ Branch 1 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 7 times.
7 if (!isAbsolute() && rTUnit && rTUnit->isAbsolute()) {
48 ✗ setAsAbsolute();
49 }
50 7 }
51
52 3148 TemperatureUnit_Impl::TemperatureUnit_Impl(bool absolute, int scaleExponent, const std::string& prettyString, int numBaseUnits, UnitSystem system)
53 3148 : Unit_Impl(scaleExponent, prettyString, numBaseUnits, system), m_absolute(absolute) {}
54
55 ✗ TemperatureUnit_Impl::TemperatureUnit_Impl(bool absolute, const std::string& scaleAbbreviation, const std::string& prettyString, int numBaseUnits,
56 ✗ UnitSystem system)
57 ✗ : Unit_Impl(scaleAbbreviation, prettyString, numBaseUnits, system), m_absolute(absolute) {}
58
59 } // namespace detail
60
61 1547 bool TemperatureUnit::isAbsolute() const {
62
1/1
✓ Branch 3 taken 1547 times.
1547 return getImpl<detail::TemperatureUnit_Impl>()->isAbsolute();
63 }
64
65 11 void TemperatureUnit::setAsAbsolute() {
66
1/1
✓ Branch 3 taken 11 times.
11 getImpl<detail::TemperatureUnit_Impl>()->setAsAbsolute();
67 11 }
68
69 47 void TemperatureUnit::setAsRelative() {
70
1/1
✓ Branch 3 taken 47 times.
47 getImpl<detail::TemperatureUnit_Impl>()->setAsRelative();
71 47 }
72
73 /// @cond
74
1/1
✓ Branch 2 taken 6944 times.
6944 TemperatureUnit::TemperatureUnit(std::shared_ptr<detail::TemperatureUnit_Impl> impl) : Unit(std::dynamic_pointer_cast<detail::Unit_Impl>(impl)) {}
75 /// @endcond
76
77 } // namespace openstudio
78