2018-03-02 10:03:01 -06:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
#include "RiaEclipseUnitTools.h"
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-03-02 10:03:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
TEST( RiaEclipseUnitTools, TestConversionToMeter )
|
2018-03-02 10:03:01 -06:00
|
|
|
{
|
|
|
|
double deltaRange = 1e-7;
|
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double sourceValue = RiaEclipseUnitTools::feetPerMeter();
|
|
|
|
QString unitText = "ft";
|
|
|
|
double destValue = RiaEclipseUnitTools::convertToMeter( sourceValue, unitText );
|
|
|
|
EXPECT_NEAR( 1.0, destValue, deltaRange );
|
2018-03-02 10:03:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double sourceValue = RiaEclipseUnitTools::feetPerMeter() * 12.0;
|
|
|
|
QString unitText = "in";
|
|
|
|
double destValue = RiaEclipseUnitTools::convertToMeter( sourceValue, unitText );
|
|
|
|
EXPECT_NEAR( 1.0, destValue, deltaRange );
|
2018-03-02 10:03:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double sourceValue = 1.0;
|
|
|
|
QString unitText = "m";
|
|
|
|
double destValue = RiaEclipseUnitTools::convertToMeter( sourceValue, unitText );
|
|
|
|
EXPECT_NEAR( 1.0, destValue, deltaRange );
|
2018-03-02 10:03:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double sourceValue = 100.0;
|
|
|
|
QString unitText = "cm";
|
|
|
|
double destValue = RiaEclipseUnitTools::convertToMeter( sourceValue, unitText );
|
|
|
|
EXPECT_NEAR( 1.0, destValue, deltaRange );
|
2018-03-02 10:03:01 -06:00
|
|
|
}
|
2018-11-19 03:39:15 -06:00
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double sourceValue = 123.0;
|
|
|
|
QString unitText = "mm";
|
|
|
|
double destValue = RiaEclipseUnitTools::convertToMeter( sourceValue, unitText );
|
|
|
|
EXPECT_NEAR( 0.123, destValue, deltaRange );
|
2018-11-19 03:39:15 -06:00
|
|
|
}
|
2018-03-02 10:03:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-03-02 10:03:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
TEST( RiaEclipseUnitTools, TestConversionToFeet )
|
2018-03-02 10:03:01 -06:00
|
|
|
{
|
|
|
|
double deltaRange = 1e-7;
|
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double sourceValue = 1.0;
|
|
|
|
QString unitText = "ft";
|
|
|
|
double destValue = RiaEclipseUnitTools::convertToFeet( sourceValue, unitText );
|
|
|
|
EXPECT_NEAR( 1.0, destValue, deltaRange );
|
2018-03-02 10:03:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double sourceValue = 1.0 * 12.0;
|
|
|
|
QString unitText = "in";
|
|
|
|
double destValue = RiaEclipseUnitTools::convertToFeet( sourceValue, unitText );
|
|
|
|
EXPECT_NEAR( 1.0, destValue, deltaRange );
|
2018-03-02 10:03:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double sourceValue = RiaEclipseUnitTools::meterPerFeet();
|
|
|
|
QString unitText = "m";
|
|
|
|
double destValue = RiaEclipseUnitTools::convertToFeet( sourceValue, unitText );
|
|
|
|
EXPECT_NEAR( 1.0, destValue, deltaRange );
|
2018-03-02 10:03:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double sourceValue = RiaEclipseUnitTools::meterPerFeet() * 100.0;
|
|
|
|
QString unitText = "cm";
|
|
|
|
double destValue = RiaEclipseUnitTools::convertToFeet( sourceValue, unitText );
|
|
|
|
EXPECT_NEAR( 1.0, destValue, deltaRange );
|
2018-03-02 10:03:01 -06:00
|
|
|
}
|
|
|
|
}
|