-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c75cf2
commit c774ede
Showing
7 changed files
with
119 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "WeatherHelper.h" | ||
|
||
namespace faker | ||
{ | ||
double WeatherHelper::celsiusToFahrenheit(double celsius) | ||
{ | ||
return (celsius * 9.0 / 5.0) + 32; | ||
} | ||
|
||
double WeatherHelper::kPaToPsi(double kPa) | ||
{ | ||
return kPa * 0.14503773773375; | ||
} | ||
|
||
double WeatherHelper::milesToKilometers(double miles) | ||
{ | ||
return miles * 1.609344; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
namespace faker | ||
{ | ||
class WeatherHelper | ||
{ | ||
public: | ||
/** | ||
* @brief Converts celsius to fahrenheit | ||
* | ||
* @param celsius | ||
* | ||
* @return double | ||
* | ||
* @code | ||
* WeatherHelper::celsiusToFahrenheit(10); // 50 | ||
* @endcode | ||
*/ | ||
static double celsiusToFahrenheit(double celsius); | ||
|
||
/** | ||
* @brief Converts kPa to PSI | ||
* | ||
* @param kPa | ||
* | ||
* @return double | ||
* | ||
* @code | ||
* WeatherHelper::kPaToPsi(1000); // 145.037 | ||
* @endcode | ||
*/ | ||
static double kPaToPsi(double kPa); | ||
|
||
/** | ||
* @brief Converts miles to kilometers | ||
* | ||
* @param miles | ||
* | ||
* @return double | ||
* | ||
* @code | ||
* WeatherHelper::milesToKilometers(10); // 16.0934 | ||
* @endcode | ||
*/ | ||
static double milesToKilometers(double miles); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "WeatherHelper.h" | ||
#include "gtest/gtest.h" | ||
|
||
using namespace faker; | ||
using namespace ::testing; | ||
|
||
class WeatherHelperTest : public Test { | ||
public: | ||
}; | ||
|
||
TEST_F(WeatherHelperTest, shouldConvertCelsiusToFahrenheit) { | ||
double celsius = 10.0; | ||
double fahrenheit = WeatherHelper::celsiusToFahrenheit(celsius); | ||
|
||
ASSERT_EQ(fahrenheit, 50.0); | ||
} | ||
|
||
TEST_F(WeatherHelperTest, shouldConvertKPaToPsi) { | ||
double kPa = 100.0; | ||
double psi = WeatherHelper::kPaToPsi(kPa); | ||
|
||
ASSERT_EQ(psi, 14.503773773375); | ||
} | ||
|
||
TEST_F(WeatherHelperTest, shouldConvertMilesToKilometers) { | ||
double miles = 10.0; | ||
double kilometers = WeatherHelper::milesToKilometers(miles); | ||
|
||
ASSERT_EQ(kilometers, 16.09344); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters