GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 64.5% 20 / 0 / 31
Functions: 66.7% 6 / 0 / 9
Branches: 40.0% 20 / 0 / 50

src/utilities/units/FahrenheitUnit.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 "FahrenheitUnit.hpp"
7 #include "FahrenheitUnit_Impl.hpp"
8
9 #include "../core/Assert.hpp"
10
11 namespace openstudio {
12 namespace detail {
13
14 132 FahrenheitUnit_Impl::FahrenheitUnit_Impl(int FExp, int scaleExponent, const std::string& prettyString)
15
2/2
✓ Branch 1 taken 132 times.
✓ Branch 4 taken 132 times.
132 : TemperatureUnit_Impl(true, scaleExponent, prettyString, 1, UnitSystem::Fahrenheit) {
16
1/1
✓ Branch 2 taken 132 times.
132 m_units[0].first = "F";
17 132 m_units[0].second = FExp;
18 132 }
19
20 ✗ FahrenheitUnit_Impl::FahrenheitUnit_Impl(const std::string& scaleAbbreviation, int FExp, const std::string& prettyString)
21 ✗ : TemperatureUnit_Impl(true, scaleAbbreviation, prettyString, 1, UnitSystem::Fahrenheit) {
22 ✗ m_units[0].first = "F";
23 ✗ m_units[0].second = FExp;
24 ✗ }
25
26 348 Unit FahrenheitUnit_Impl::clone() const {
27
3/5
✓ Branch 1 taken 348 times.
✓ Branch 4 taken 348 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 348 times.
✗ Branch 10 not taken.
348 OS_ASSERT(system() == UnitSystem::Fahrenheit);
28
3/5
✓ Branch 1 taken 348 times.
✓ Branch 4 taken 348 times.
✓ Branch 7 taken 348 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
348 std::shared_ptr<FahrenheitUnit_Impl> impl(new FahrenheitUnit_Impl(*this));
29
2/2
✓ Branch 2 taken 348 times.
✓ Branch 5 taken 348 times.
696 return FahrenheitUnit(impl).cast<Unit>();
30 348 }
31
32 8 void FahrenheitUnit_Impl::setBaseUnitExponent(const std::string& baseUnit, int exponent) {
33
1/1
✓ Branch 1 taken 8 times.
8 auto loc = findBaseUnit(baseUnit);
34
1/2
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (loc != m_units.end()) {
35 8 loc->second = exponent;
36 } else {
37 ✗ LOG_AND_THROW("Cannot add base units to an instance of FahrenheitUnit.");
38 }
39 8 }
40
41 } // namespace detail
42
43 132 FahrenheitUnit::FahrenheitUnit(int FExp, int scaleExponent, const std::string& prettyString)
44
4/6
✓ Branch 1 taken 132 times.
✓ Branch 4 taken 132 times.
✓ Branch 7 taken 132 times.
✓ Branch 11 taken 132 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
132 : TemperatureUnit(std::shared_ptr<detail::FahrenheitUnit_Impl>(new detail::FahrenheitUnit_Impl(FExp, scaleExponent, prettyString))) {}
45
46 ✗ FahrenheitUnit::FahrenheitUnit(const std::string& scaleAbbreviation, int FExp, const std::string& prettyString)
47 ✗ : TemperatureUnit(std::shared_ptr<detail::FahrenheitUnit_Impl>(new detail::FahrenheitUnit_Impl(scaleAbbreviation, FExp, prettyString))) {}
48
49 ✗ FahrenheitUnit& FahrenheitUnit::operator/=(const FahrenheitUnit& rUnit) {
50 ✗ getImpl<detail::FahrenheitUnit_Impl>()->operator/=(rUnit);
51 ✗ return *this;
52 }
53
54 /// @cond
55
1/1
✓ Branch 2 taken 350 times.
350 FahrenheitUnit::FahrenheitUnit(std::shared_ptr<detail::FahrenheitUnit_Impl> impl) : TemperatureUnit(impl) {}
56 /// @endcond
57
58 117 FahrenheitUnit createFahrenheitTemperature() {
59
2/2
✓ Branch 1 taken 117 times.
✓ Branch 4 taken 117 times.
234 return FahrenheitUnit(1);
60 }
61
62 } // namespace openstudio
63