GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 68.0% 70 / 0 / 103
Functions: 86.4% 19 / 0 / 22
Branches: 58.4% 59 / 0 / 101

src/utilities/units/GPDUnit.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 "GPDUnit.hpp"
7 #include "GPDUnit_Impl.hpp"
8
9 #include "../core/Assert.hpp"
10
11 namespace openstudio {
12 namespace detail {
13
14 1538 GPDUnit_Impl::GPDUnit_Impl(const GPDExpnt& exponents, int scaleExponent, const std::string& prettyString)
15
2/2
✓ Branch 1 taken 1538 times.
✓ Branch 4 taken 1538 times.
1538 : Unit_Impl(scaleExponent, prettyString, 12, UnitSystem::GPD) {
16
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[0].first = "inH_{2}O";
17 1538 m_units[0].second = exponents.m_inH2O;
18
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[1].first = "crgal";
19 1538 m_units[1].second = exponents.m_crgal;
20
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[2].first = "day";
21 1538 m_units[2].second = exponents.m_day;
22
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[3].first = "R";
23 1538 m_units[3].second = exponents.m_R;
24
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[4].first = "A";
25 1538 m_units[4].second = exponents.m_A;
26
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[5].first = "cd";
27 1538 m_units[5].second = exponents.m_cd;
28
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[6].first = "lbmol";
29 1538 m_units[6].second = exponents.m_lbmol;
30
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[7].first = "deg";
31 1538 m_units[7].second = exponents.m_deg;
32
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[8].first = "sr";
33 1538 m_units[8].second = exponents.m_sr;
34
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[9].first = "people";
35 1538 m_units[9].second = exponents.m_people;
36
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[10].first = "cycle";
37 1538 m_units[10].second = exponents.m_cycle;
38
1/1
✓ Branch 2 taken 1538 times.
1538 m_units[11].first = "$";
39 1538 m_units[11].second = exponents.m_dollar;
40 1538 }
41
42 ✗ GPDUnit_Impl::GPDUnit_Impl(const std::string& scaleAbbreviation, const GPDExpnt& exponents, const std::string& prettyString)
43 ✗ : Unit_Impl(scaleAbbreviation, prettyString, 12, UnitSystem::GPD) {
44 ✗ m_units[0].first = "inH_{2}O";
45 ✗ m_units[0].second = exponents.m_inH2O;
46 ✗ m_units[1].first = "crgal";
47 ✗ m_units[1].second = exponents.m_crgal;
48 ✗ m_units[2].first = "day";
49 ✗ m_units[2].second = exponents.m_day;
50 ✗ m_units[3].first = "R";
51 ✗ m_units[3].second = exponents.m_R;
52 ✗ m_units[4].first = "A";
53 ✗ m_units[4].second = exponents.m_A;
54 ✗ m_units[5].first = "cd";
55 ✗ m_units[5].second = exponents.m_cd;
56 ✗ m_units[6].first = "lbmol";
57 ✗ m_units[6].second = exponents.m_lbmol;
58 ✗ m_units[7].first = "deg";
59 ✗ m_units[7].second = exponents.m_deg;
60 ✗ m_units[8].first = "sr";
61 ✗ m_units[8].second = exponents.m_sr;
62 ✗ m_units[9].first = "people";
63 ✗ m_units[9].second = exponents.m_people;
64 ✗ m_units[10].first = "cycle";
65 ✗ m_units[10].second = exponents.m_cycle;
66 ✗ m_units[11].first = "$";
67 ✗ m_units[11].second = exponents.m_dollar;
68 ✗ }
69
70 393 Unit GPDUnit_Impl::clone() const {
71
3/5
✓ Branch 1 taken 393 times.
✓ Branch 4 taken 393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 393 times.
✗ Branch 10 not taken.
393 OS_ASSERT(system() == UnitSystem::GPD);
72
3/5
✓ Branch 1 taken 393 times.
✓ Branch 4 taken 393 times.
✓ Branch 7 taken 393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
393 std::shared_ptr<GPDUnit_Impl> impl(new GPDUnit_Impl(*this));
73
2/2
✓ Branch 2 taken 393 times.
✓ Branch 5 taken 393 times.
786 return GPDUnit(impl).cast<Unit>();
74 393 }
75
76 100 void GPDUnit_Impl::setBaseUnitExponent(const std::string& baseUnit, int exponent) {
77
1/1
✓ Branch 1 taken 100 times.
100 auto loc = findBaseUnit(baseUnit);
78
1/2
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if (loc != m_units.end()) {
79 100 loc->second = exponent;
80 } else {
81 ✗ LOG_AND_THROW("Cannot add base units to an instance of GPDUnit.");
82 }
83 100 }
84
85 } // namespace detail
86
87 1538 GPDUnit::GPDUnit(const GPDExpnt& exponents, int scaleExponent, const std::string& prettyString)
88
4/6
✓ Branch 1 taken 1538 times.
✓ Branch 4 taken 1538 times.
✓ Branch 7 taken 1538 times.
✓ Branch 10 taken 1538 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1538 : Unit(std::shared_ptr<detail::Unit_Impl>(new detail::GPDUnit_Impl(exponents, scaleExponent, prettyString))) {}
89
90 ✗ GPDUnit::GPDUnit(const std::string& scaleAbbreviation, const GPDExpnt& exponents, const std::string& prettyString)
91 ✗ : Unit(std::shared_ptr<detail::Unit_Impl>(new detail::GPDUnit_Impl(scaleAbbreviation, exponents, prettyString))) {}
92
93 /// @cond
94
1/1
✓ Branch 2 taken 393 times.
393 GPDUnit::GPDUnit(std::shared_ptr<detail::GPDUnit_Impl> impl) : Unit(std::dynamic_pointer_cast<detail::Unit_Impl>(impl)) {}
95 /// @endcond
96
97 113 GPDUnit createGPDPressure() {
98
2/2
✓ Branch 1 taken 113 times.
✓ Branch 5 taken 113 times.
226 return GPDUnit(GPDExpnt(1));
99 }
100
101 100 GPDUnit createGPDLength() {
102
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
100 GPDUnit result;
103
2/2
✓ Branch 1 taken 100 times.
✓ Branch 4 taken 100 times.
200 result.setBaseUnitExponent("crgal", 1);
104 100 return result;
105 ✗ }
106
107 117 GPDUnit createGPDTime() {
108
2/2
✓ Branch 1 taken 117 times.
✓ Branch 5 taken 117 times.
234 return GPDUnit(GPDExpnt(0, 0, 1));
109 }
110
111 100 GPDUnit createGPDTemperature() {
112
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return GPDUnit(GPDExpnt(0, 0, 0, 1));
113 }
114
115 100 GPDUnit createGPDElectricCurrent() {
116
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return GPDUnit(GPDExpnt(0, 0, 0, 0, 1));
117 }
118
119 100 GPDUnit createGPDLuminousIntensity() {
120
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return GPDUnit(GPDExpnt(0, 0, 0, 0, 0, 1));
121 }
122
123 100 GPDUnit createGPDAmountOfSubstance() {
124
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return GPDUnit(GPDExpnt(0, 0, 0, 0, 0, 0, 1));
125 }
126
127 100 GPDUnit createGPDAngle() {
128
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return GPDUnit(GPDExpnt(0, 0, 0, 0, 0, 0, 0, 1));
129 }
130
131 100 GPDUnit createGPDSolidAngle() {
132
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return GPDUnit(GPDExpnt(0, 0, 0, 0, 0, 0, 0, 0, 1));
133 }
134
135 103 GPDUnit createGPDPeople() {
136
2/2
✓ Branch 1 taken 103 times.
✓ Branch 5 taken 103 times.
206 return GPDUnit(GPDExpnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
137 }
138
139 100 GPDUnit createGPDCycle() {
140
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return GPDUnit(GPDExpnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
141 }
142
143 ✗ GPDUnit createGPDCurrency() {
144 ✗ return GPDUnit(GPDExpnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
145 }
146
147 205 GPDUnit createGPDVolume() {
148
2/2
✓ Branch 1 taken 205 times.
✓ Branch 5 taken 205 times.
410 return GPDUnit(GPDExpnt(0, 1), 0, "gal");
149 }
150
151 100 GPDUnit createGPDVolumetricFlowrate() {
152
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return GPDUnit(GPDExpnt(0, 1, -1), 0, "gpd");
153 }
154
155 100 GPDUnit createGPDLuminousFlux() {
156
2/2
✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
200 return GPDUnit(GPDExpnt(0, 0, 0, 0, 0, 1, 0, 0, 1), 0, "lm");
157 }
158
159 } // namespace openstudio
160