GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 97 / 0 / 97
Functions: 100.0% 33 / 0 / 33
Branches: 76.4% 84 / 0 / 110

src/utilities/units/Scale.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 "Scale.hpp"
7
8 namespace openstudio {
9
10 144 std::ostream& operator<<(std::ostream& os, const Scale& s) {
11 144 os << s.name << ", " << s.abbr << ", 10^";
12
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 75 times.
144 if (s.exponent < 0) {
13 69 os << "{" << s.exponent << "}";
14 } else {
15 75 os << s.exponent;
16 }
17 144 os << " = " << s.value;
18
19 144 return os;
20 }
21
22 55 bool operator==(const Scale& firstScale, const Scale& secondScale) {
23
4/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 53 times.
✓ Branch 4 taken 1 time.
55 return ((firstScale.exponent == secondScale.exponent) && (firstScale.abbr == secondScale.abbr));
24 }
25
26 53 bool operator!=(const Scale& firstScale, const Scale& secondScale) {
27 53 return !(firstScale == secondScale);
28 }
29
30 1 bool operator<(const Scale& firstScale, const Scale& secondScale) {
31 1 return (firstScale.exponent < secondScale.exponent);
32 }
33
34 1 bool operator>(const Scale& firstScale, const Scale& secondScale) {
35 1 return (firstScale.exponent > secondScale.exponent);
36 }
37
38 1 bool operator<=(const Scale& firstScale, const Scale& secondScale) {
39 1 return (firstScale.exponent <= secondScale.exponent);
40 }
41
42 1 bool operator>=(const Scale& firstScale, const Scale& secondScale) {
43 1 return (firstScale.exponent >= secondScale.exponent);
44 }
45
46 /** Static constant indicating that the scale was not found. To test for it,
47 * check that value == 0. */
48 9 const Scale& notDefined() {
49
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
9 static const Scale ND = {"ND", "Not Defined", 0, 0.0};
50 9 return ND;
51 }
52
53 /** Static constant defining SI prefix for 10^24. */
54 3883 const Scale& yotta() {
55
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale Y = {"Y", "yotta", 24, 1.0E24};
56 3883 return Y;
57 }
58
59 /** Static constant defining SI prefix for 10^21. */
60 3883 const Scale& zetta() {
61
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale Z = {"Z", "zetta", 21, 1.0E21};
62 3883 return Z;
63 }
64
65 /** Static constant defining SI prefix for 10^18. */
66 3883 const Scale& exa() {
67
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale E = {"E", "exa", 18, 1.0E18};
68 3883 return E;
69 }
70
71 /** Static constant defining SI prefix for 10^15. */
72 3887 const Scale& peta() {
73
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1999 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3887 static const Scale P = {"P", "peta", 15, 1.0E15};
74 3887 return P;
75 }
76
77 /** Static constant defining SI prefix for 10^12. */
78 3883 const Scale& tera() {
79
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale T = {"T", "tera", 12, 1.0E12};
80 3883 return T;
81 }
82
83 /** Static constant defining SI prefix for 10^9. */
84 3918 const Scale& giga() {
85
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2030 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3918 static const Scale G = {"G", "giga", 9, 1.0E9};
86 3918 return G;
87 }
88
89 /** Static constant defining SI prefix for 10^6. */
90 4489 const Scale& mega() {
91
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2601 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
4489 static const Scale M = {"M", "mega", 6, 1.0E6};
92 4489 return M;
93 }
94
95 /** Static constant defining SI prefix for 10^5. */
96 3882 UTILITIES_API const Scale& hectokilo() {
97
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1994 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3882 static const Scale hk = {"_hk", "hectokilo", 5, 1.0E5};
98 3882 return hk;
99 }
100
101 /** Static constant defining SI prefix for 10^4. */
102 3908 const Scale& myria() {
103
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2020 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3908 static const Scale k = {"_ma", "myria", 4, 1.0E4};
104 3908 return k;
105 }
106
107 /** Static constant defining SI prefix for 10^3. */
108 4342 const Scale& kilo() {
109
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2454 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
4342 static const Scale k = {"k", "kilo", 3, 1.0E3};
110 4342 return k;
111 }
112
113 /** Static constant defining SI prefix for 10^2. */
114 3898 UTILITIES_API const Scale& hecto() {
115
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2010 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3898 static const Scale h = {"_h", "hecto", 2, 1.0E2};
116 3898 return h;
117 }
118
119 /** Static constant defining SI prefix for 10^1. */
120 3883 UTILITIES_API const Scale& deka() {
121
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale da = {"_da", "deka", 1, 1.0E1};
122 3883 return da;
123 }
124
125 /** Static constant defining no scale (1.0). */
126 228877 const Scale& one() {
127
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 226989 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
228877 static const Scale o = {"", "", 0, 1.0};
128 228877 return o;
129 }
130
131 /** Static constant defining SI prefix for 10^{-1} */
132 3883 const Scale& deci() {
133
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale d = {"_d", "deci", -1, 1.0E-1};
134 3883 return d;
135 }
136
137 /** Static constant defining SI prefix for 10^{-2} */
138 4036 const Scale& centi() {
139
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2148 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
4036 static const Scale c = {"c", "centi", -2, 1.0E-2};
140 4036 return c;
141 }
142
143 /** Static constant defining SI prefix for 10^{-3} */
144 4195 const Scale& milli() {
145
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2307 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
4195 static const Scale m = {"m", "milli", -3, 1.0E-3};
146 4195 return m;
147 }
148
149 /** Static constant defining SI prefix for 10^{-4} */
150 3951 const Scale& decimilli() {
151
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2063 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3951 static const Scale dm = {"_dm", "decimilli", -4, 1.0E-4};
152 3951 return dm;
153 }
154
155 /** Static constant defining SI prefix for 10^{-5} */
156 3882 const Scale& centimilli() {
157
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1994 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3882 static const Scale cm = {"_cm", "centimilli", -5, 1.0E-5};
158 3882 return cm;
159 }
160
161 /** Static constant defining SI prefix for 10^{-6} */
162 4416 const Scale& micro() {
163
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2528 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
4416 static const Scale mu = {"\\mu", "micro", -6, 1.0E-6};
164 4416 return mu;
165 }
166
167 /** Static constant defining SI prefix for 10^{-9} */
168 3910 const Scale& nano() {
169
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2022 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3910 static const Scale n = {"n", "nano", -9, 1.0E-9};
170 3910 return n;
171 }
172
173 /** Static constant defining SI prefix for 10^{-12} */
174 3892 const Scale& pico() {
175
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 2004 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3892 static const Scale p = {"p", "pico", -12, 1.0E-12};
176 3892 return p;
177 }
178
179 /** Static constant defining SI prefix for 10^{-15} */
180 3883 const Scale& femto() {
181
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale f = {"f", "femto", -15, 1.0E-15};
182 3883 return f;
183 }
184
185 /** Static constant defining SI prefix for 10^{-18) */
186 3883 const Scale& atto() {
187
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale a = {"a", "atto", -18, 1.0E-18};
188 3883 return a;
189 }
190
191 /** Static constant defining SI prefix for 10^{-21} */
192 3883 const Scale& zepto() {
193
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale z = {"z", "zepto", -21, 1.0E-21};
194 3883 return z;
195 }
196
197 /** Static constant defining SI prefix for 10^{-24} */
198 3883 const Scale& yocto() {
199
3/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1995 times.
✓ Branch 3 taken 1888 times.
✗ Branch 4 not taken.
3883 static const Scale y = {"y", "yocto", -24, 1.0E-24};
200 3883 return y;
201 }
202
203 } // namespace openstudio
204