GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 68.6% 70 / 0 / 102
Functions: 87.0% 20 / 0 / 23
Branches: 58.4% 59 / 0 / 101

src/utilities/units/CFMUnit.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 "CFMUnit.hpp"
7 #include "CFMUnit_Impl.hpp"
8
9 #include "../core/Assert.hpp"
10
11 namespace openstudio {
12
13 namespace detail {
14
15 1644 CFMUnit_Impl::CFMUnit_Impl(const CFMExpnt& exponents, int scaleExponent, const std::string& prettyString)
16
2/2
✓ Branch 1 taken 1644 times.
✓ Branch 4 taken 1644 times.
1644 : Unit_Impl(scaleExponent, prettyString, 12, UnitSystem::CFM) {
17
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[0].first = "ft";
18 1644 m_units[0].second = exponents.m_ft;
19
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[1].first = "min";
20 1644 m_units[1].second = exponents.m_min;
21
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[2].first = "ton";
22 1644 m_units[2].second = exponents.m_ton;
23
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[3].first = "R";
24 1644 m_units[3].second = exponents.m_R;
25
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[4].first = "A";
26 1644 m_units[4].second = exponents.m_A;
27
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[5].first = "cd";
28 1644 m_units[5].second = exponents.m_cd;
29
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[6].first = "lbmol";
30 1644 m_units[6].second = exponents.m_lbmol;
31
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[7].first = "deg";
32 1644 m_units[7].second = exponents.m_deg;
33
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[8].first = "sr";
34 1644 m_units[8].second = exponents.m_sr;
35
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[9].first = "people";
36 1644 m_units[9].second = exponents.m_people;
37
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[10].first = "cycle";
38 1644 m_units[10].second = exponents.m_cycle;
39
1/1
✓ Branch 2 taken 1644 times.
1644 m_units[11].first = "$";
40 1644 m_units[11].second = exponents.m_dollar;
41 1644 }
42
43 ✗ CFMUnit_Impl::CFMUnit_Impl(const std::string& scaleAbbreviation, const CFMExpnt& exponents, const std::string& prettyString)
44 ✗ : Unit_Impl(scaleAbbreviation, prettyString, 12, UnitSystem::CFM) {
45 ✗ m_units[0].first = "ft";
46 ✗ m_units[0].second = exponents.m_ft;
47 ✗ m_units[1].first = "min";
48 ✗ m_units[1].second = exponents.m_min;
49 ✗ m_units[2].first = "ton";
50 ✗ m_units[2].second = exponents.m_ton;
51 ✗ m_units[3].first = "R";
52 ✗ m_units[3].second = exponents.m_R;
53 ✗ m_units[4].first = "A";
54 ✗ m_units[4].second = exponents.m_A;
55 ✗ m_units[5].first = "cd";
56 ✗ m_units[5].second = exponents.m_cd;
57 ✗ m_units[6].first = "lbmol";
58 ✗ m_units[6].second = exponents.m_lbmol;
59 ✗ m_units[7].first = "deg";
60 ✗ m_units[7].second = exponents.m_deg;
61 ✗ m_units[8].first = "sr";
62 ✗ m_units[8].second = exponents.m_sr;
63 ✗ m_units[9].first = "people";
64 ✗ m_units[9].second = exponents.m_people;
65 ✗ m_units[10].first = "cycle";
66 ✗ m_units[10].second = exponents.m_cycle;
67 ✗ m_units[11].first = "$";
68 ✗ m_units[11].second = exponents.m_dollar;
69 ✗ }
70
71 920 Unit CFMUnit_Impl::clone() const {
72
3/5
✓ Branch 1 taken 920 times.
✓ Branch 4 taken 920 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 920 times.
✗ Branch 10 not taken.
920 OS_ASSERT(system() == UnitSystem::CFM);
73
3/5
✓ Branch 1 taken 920 times.
✓ Branch 4 taken 920 times.
✓ Branch 7 taken 920 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
920 std::shared_ptr<CFMUnit_Impl> impl(new CFMUnit_Impl(*this));
74
2/2
✓ Branch 2 taken 920 times.
✓ Branch 5 taken 920 times.
1840 return CFMUnit(impl).cast<Unit>();
75 920 }
76
77 308 void CFMUnit_Impl::setBaseUnitExponent(const std::string& baseUnit, int exponent) {
78
1/1
✓ Branch 1 taken 308 times.
308 auto loc = findBaseUnit(baseUnit);
79
1/2
✓ Branch 2 taken 308 times.
✗ Branch 3 not taken.
308 if (loc != m_units.end()) {
80 308 loc->second = exponent;
81 } else {
82 ✗ LOG_AND_THROW("Cannot add base units to an instance of CFMUnit.");
83 }
84 308 }
85
86 } // namespace detail
87
88 1644 CFMUnit::CFMUnit(const CFMExpnt& exponents, int scaleExponent, const std::string& prettyString)
89
4/6
✓ Branch 1 taken 1644 times.
✓ Branch 4 taken 1644 times.
✓ Branch 7 taken 1644 times.
✓ Branch 10 taken 1644 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1644 : Unit(std::shared_ptr<detail::Unit_Impl>(new detail::CFMUnit_Impl(exponents, scaleExponent, prettyString))) {}
90
91 ✗ CFMUnit::CFMUnit(const std::string& scaleAbbreviation, const CFMExpnt& exponents, const std::string& prettyString)
92 ✗ : Unit(std::shared_ptr<detail::Unit_Impl>(new detail::CFMUnit_Impl(scaleAbbreviation, exponents, prettyString))) {}
93
94 /// @cond
95
1/1
✓ Branch 2 taken 921 times.
921 CFMUnit::CFMUnit(std::shared_ptr<detail::CFMUnit_Impl> impl) : Unit(std::dynamic_pointer_cast<detail::Unit_Impl>(impl)) {}
96 /// @endcond
97
98 109 CFMUnit createCFMLength() {
99
2/2
✓ Branch 1 taken 109 times.
✓ Branch 5 taken 109 times.
218 return CFMUnit(CFMExpnt(1));
100 }
101
102 168 CFMUnit createCFMTime() {
103
2/2
✓ Branch 1 taken 168 times.
✓ Branch 5 taken 168 times.
336 return CFMUnit(CFMExpnt(0, 1));
104 }
105
106 101 CFMUnit createCFMPower() {
107
2/2
✓ Branch 1 taken 101 times.
✓ Branch 5 taken 101 times.
202 return CFMUnit(CFMExpnt(0, 0, 1));
108 }
109
110 101 CFMUnit createCFMTemperature() {
111
2/2
✓ Branch 1 taken 101 times.
✓ Branch 5 taken 101 times.
202 return CFMUnit(CFMExpnt(0, 0, 0, 1));
112 }
113
114 100 CFMUnit createCFMElectricCurrent() {
115
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return CFMUnit(CFMExpnt(0, 0, 0, 0, 1));
116 }
117
118 100 CFMUnit createCFMLuminousIntensity() {
119
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return CFMUnit(CFMExpnt(0, 0, 0, 0, 0, 1));
120 }
121
122 100 CFMUnit createCFMAmountOfSubstance() {
123
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return CFMUnit(CFMExpnt(0, 0, 0, 0, 0, 0, 1));
124 }
125
126 100 CFMUnit createCFMAngle() {
127
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return CFMUnit(CFMExpnt(0, 0, 0, 0, 0, 0, 0, 1));
128 }
129
130 100 CFMUnit createCFMSolidAngle() {
131
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return CFMUnit(CFMExpnt(0, 0, 0, 0, 0, 0, 0, 0, 1));
132 }
133
134 104 CFMUnit createCFMPeople() {
135
2/2
✓ Branch 1 taken 104 times.
✓ Branch 5 taken 104 times.
208 return CFMUnit(CFMExpnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
136 }
137
138 100 CFMUnit createCFMCycle() {
139
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return CFMUnit(CFMExpnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
140 }
141
142 ✗ CFMUnit createCFMCurrency() {
143 ✗ return CFMUnit(CFMExpnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
144 }
145
146 115 CFMUnit createCFMVolumetricFlowrate() {
147
2/2
✓ Branch 1 taken 115 times.
✓ Branch 5 taken 115 times.
230 return CFMUnit(CFMExpnt(3, -1), 0, "cfm");
148 }
149
150 100 CFMUnit createCFMLuminousFlux() {
151
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return CFMUnit(CFMExpnt(0, 0, 0, 0, 0, 1, 0, 0, 1), 0, "lm");
152 }
153
154 100 CFMUnit createCFMIlluminance() {
155
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return CFMUnit(CFMExpnt(-2, 0, 0, 0, 0, 1, 0, 0, 1), 0, "fc");
156 }
157
158 123 CFMUnit createCFMFrequency() {
159
2/2
✓ Branch 1 taken 123 times.
✓ Branch 5 taken 123 times.
246 return CFMUnit(CFMExpnt(0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1), 0, "rpm");
160 }
161
162 } // namespace openstudio
163