UDAValue: the get<double>() method will return SI values
This commit is contained in:
parent
f3abbf4981
commit
44e21101bc
@ -67,8 +67,9 @@ bool UDAValue::is<std::string>() const {
|
||||
|
||||
template<>
|
||||
double UDAValue::get() const {
|
||||
if (this->numeric_value)
|
||||
return this->double_value;
|
||||
this->assert_numeric();
|
||||
return this->dim.convertRawToSi(this->double_value);
|
||||
}
|
||||
|
||||
throw std::invalid_argument("UDAValue does not hold a numerical value");
|
||||
}
|
||||
|
@ -1056,3 +1056,16 @@ BOOST_AUTO_TEST_CASE(UDA_VALUE) {
|
||||
BOOST_CHECK_EQUAL( value2.get<std::string>(), std::string("FUBHP"));
|
||||
BOOST_CHECK_THROW( value2.get<double>(), std::invalid_argument);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The unit/dimension handling in the UDAvalue is hacky at best.
|
||||
*/
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UDA_VALUE_DIM) {
|
||||
UDAValue value0(1);
|
||||
Dimension dim("DUMMY", 10);
|
||||
BOOST_CHECK_EQUAL( value0.get<double>(), 1);
|
||||
value0.set_dim( dim );
|
||||
BOOST_CHECK_EQUAL( value0.get<double>(), 10);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user