GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 98.0% 98 / 0 / 100
Functions: 95.5% 21 / 0 / 22
Branches: 89.9% 89 / 0 / 99

src/utilities/units/BTUUnit.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 "BTUUnit.hpp"
7 #include "BTUUnit_Impl.hpp"
8
9 #include "../core/Assert.hpp"
10
11 namespace openstudio {
12
13 namespace detail {
14
15 1764 BTUUnit_Impl::BTUUnit_Impl(const BTUExpnt& exponents, int scaleExponent, const std::string& prettyString)
16
2/2
✓ Branch 1 taken 1764 times.
✓ Branch 4 taken 1764 times.
1764 : Unit_Impl(scaleExponent, prettyString, 12, UnitSystem::BTU) {
17
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[0].first = "Btu";
18 1764 m_units[0].second = exponents.m_btu;
19
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[1].first = "ft";
20 1764 m_units[1].second = exponents.m_ft;
21
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[2].first = "h";
22 1764 m_units[2].second = exponents.m_h;
23
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[3].first = "R";
24 1764 m_units[3].second = exponents.m_R;
25
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[4].first = "A";
26 1764 m_units[4].second = exponents.m_A;
27
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[5].first = "cd";
28 1764 m_units[5].second = exponents.m_cd;
29
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[6].first = "lbmol";
30 1764 m_units[6].second = exponents.m_lbmol;
31
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[7].first = "deg";
32 1764 m_units[7].second = exponents.m_deg;
33
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[8].first = "sr";
34 1764 m_units[8].second = exponents.m_sr;
35
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[9].first = "people";
36 1764 m_units[9].second = exponents.m_people;
37
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[10].first = "cycle";
38 1764 m_units[10].second = exponents.m_cycle;
39
1/1
✓ Branch 2 taken 1764 times.
1764 m_units[11].first = "$";
40 1764 m_units[11].second = exponents.m_dollar;
41 1764 }
42
43 1 BTUUnit_Impl::BTUUnit_Impl(const std::string& scaleAbbreviation, const BTUExpnt& exponents, const std::string& prettyString)
44
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 : Unit_Impl(scaleAbbreviation, prettyString, 12, UnitSystem::BTU) {
45
1/1
✓ Branch 2 taken 1 time.
1 m_units[0].first = "Btu";
46 1 m_units[0].second = exponents.m_btu;
47
1/1
✓ Branch 2 taken 1 time.
1 m_units[1].first = "ft";
48 1 m_units[1].second = exponents.m_ft;
49
1/1
✓ Branch 2 taken 1 time.
1 m_units[2].first = "h";
50 1 m_units[2].second = exponents.m_h;
51
1/1
✓ Branch 2 taken 1 time.
1 m_units[3].first = "R";
52 1 m_units[3].second = exponents.m_R;
53
1/1
✓ Branch 2 taken 1 time.
1 m_units[4].first = "A";
54 1 m_units[4].second = exponents.m_A;
55
1/1
✓ Branch 2 taken 1 time.
1 m_units[5].first = "cd";
56 1 m_units[5].second = exponents.m_cd;
57
1/1
✓ Branch 2 taken 1 time.
1 m_units[6].first = "lbmol";
58 1 m_units[6].second = exponents.m_lbmol;
59
1/1
✓ Branch 2 taken 1 time.
1 m_units[7].first = "deg";
60 1 m_units[7].second = exponents.m_deg;
61
1/1
✓ Branch 2 taken 1 time.
1 m_units[8].first = "sr";
62 1 m_units[8].second = exponents.m_sr;
63
1/1
✓ Branch 2 taken 1 time.
1 m_units[9].first = "people";
64 1 m_units[9].second = exponents.m_people;
65
1/1
✓ Branch 2 taken 1 time.
1 m_units[10].first = "cycle";
66 1 m_units[10].second = exponents.m_cycle;
67
1/1
✓ Branch 2 taken 1 time.
1 m_units[11].first = "$";
68 1 m_units[11].second = exponents.m_dollar;
69 1 }
70
71 914 Unit BTUUnit_Impl::clone() const {
72
3/5
✓ Branch 1 taken 914 times.
✓ Branch 4 taken 914 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 914 times.
✗ Branch 10 not taken.
914 OS_ASSERT(system() == UnitSystem::BTU);
73
3/5
✓ Branch 1 taken 914 times.
✓ Branch 4 taken 914 times.
✓ Branch 7 taken 914 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
914 std::shared_ptr<BTUUnit_Impl> impl(new BTUUnit_Impl(*this));
74
2/2
✓ Branch 2 taken 914 times.
✓ Branch 5 taken 914 times.
1828 return BTUUnit(impl).cast<Unit>();
75 914 }
76
77 654 void BTUUnit_Impl::setBaseUnitExponent(const std::string& baseUnit, int exponent) {
78
1/1
✓ Branch 1 taken 654 times.
654 auto loc = findBaseUnit(baseUnit);
79
2/2
✓ Branch 2 taken 653 times.
✓ Branch 3 taken 1 time.
654 if (loc != m_units.end()) {
80 653 loc->second = exponent;
81 } else {
82
13/13
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 38 taken 1 time.
✓ Branch 41 taken 1 time.
1 LOG_AND_THROW("Cannot add base units to an instance of BTUUnit.");
83 }
84 653 }
85
86 } // namespace detail
87
88 1764 BTUUnit::BTUUnit(const BTUExpnt& exponents, int scaleExponent, const std::string& prettyString)
89
4/6
✓ Branch 1 taken 1764 times.
✓ Branch 4 taken 1764 times.
✓ Branch 7 taken 1764 times.
✓ Branch 10 taken 1764 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1764 : Unit(std::shared_ptr<detail::Unit_Impl>(new detail::BTUUnit_Impl(exponents, scaleExponent, prettyString))) {}
90
91 1 BTUUnit::BTUUnit(const std::string& scaleAbbreviation, const BTUExpnt& exponents, const std::string& prettyString)
92
4/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1 : Unit(std::shared_ptr<detail::Unit_Impl>(new detail::BTUUnit_Impl(scaleAbbreviation, exponents, prettyString))) {}
93
94 /// @cond
95
1/1
✓ Branch 2 taken 918 times.
918 BTUUnit::BTUUnit(std::shared_ptr<detail::BTUUnit_Impl> impl) : Unit(std::dynamic_pointer_cast<detail::Unit_Impl>(impl)) {}
96 /// @endcond
97
98 145 BTUUnit createBTUEnergy() {
99
2/2
✓ Branch 1 taken 145 times.
✓ Branch 5 taken 145 times.
290 return BTUUnit(BTUExpnt(1));
100 }
101
102 122 BTUUnit createBTULength() {
103
2/2
✓ Branch 1 taken 122 times.
✓ Branch 5 taken 122 times.
244 return BTUUnit(BTUExpnt(0, 1));
104 }
105
106 261 BTUUnit createBTUTime() {
107
2/2
✓ Branch 1 taken 261 times.
✓ Branch 5 taken 261 times.
522 return BTUUnit(BTUExpnt(0, 0, 1));
108 }
109
110 111 BTUUnit createBTUTemperature() {
111
2/2
✓ Branch 1 taken 111 times.
✓ Branch 5 taken 111 times.
222 return BTUUnit(BTUExpnt(0, 0, 0, 1));
112 }
113
114 101 BTUUnit createBTUElectricCurrent() {
115
2/2
✓ Branch 1 taken 101 times.
✓ Branch 5 taken 101 times.
202 return BTUUnit(BTUExpnt(0, 0, 0, 0, 1));
116 }
117
118 100 BTUUnit createBTULuminousIntensity() {
119
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return BTUUnit(BTUExpnt(0, 0, 0, 0, 0, 1));
120 }
121
122 100 BTUUnit createBTUAmountOfSubstance() {
123
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return BTUUnit(BTUExpnt(0, 0, 0, 0, 0, 0, 1));
124 }
125
126 100 BTUUnit createBTUAngle() {
127
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return BTUUnit(BTUExpnt(0, 0, 0, 0, 0, 0, 0, 1));
128 }
129
130 100 BTUUnit createBTUSolidAngle() {
131
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return BTUUnit(BTUExpnt(0, 0, 0, 0, 0, 0, 0, 0, 1));
132 }
133
134 106 BTUUnit createBTUPeople() {
135
2/2
✓ Branch 1 taken 106 times.
✓ Branch 5 taken 106 times.
212 return BTUUnit(BTUExpnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
136 }
137
138 101 BTUUnit createBTUCycle() {
139
2/2
✓ Branch 1 taken 101 times.
✓ Branch 5 taken 101 times.
202 return BTUUnit(BTUExpnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
140 }
141
142 ✗ BTUUnit createBTUCurrency() {
143 ✗ return BTUUnit(BTUExpnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
144 }
145
146 130 BTUUnit createBTUPower() {
147
2/2
✓ Branch 1 taken 130 times.
✓ Branch 5 taken 130 times.
260 return BTUUnit(BTUExpnt(1, 0, -1));
148 }
149
150 100 BTUUnit createBTULuminousFlux() {
151
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return BTUUnit(BTUExpnt(0, 0, 0, 0, 0, 1, 0, 0, 1), 0, "lm");
152 }
153
154 100 BTUUnit createBTUIlluminance() {
155
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return BTUUnit(BTUExpnt(0, -2, 0, 0, 0, 1, 0, 0, 1), 0, "fc");
156 }
157
158 } // namespace openstudio
159