Added Dimension::equal() method.

This commit is contained in:
Joakim Hove
2013-12-12 12:12:45 +01:00
parent 8ff866266b
commit c86b220e40
3 changed files with 22 additions and 0 deletions

View File

@@ -56,6 +56,15 @@ namespace Opm {
return dimension;
}
bool Dimension::equal(const Dimension& other) {
if ((m_name == other.m_name) &&
(m_SIfactor == other.m_SIfactor))
return true;
else
return false;
}
}

View File

@@ -28,6 +28,7 @@ namespace Opm {
public:
Dimension(const std::string& name, double SI_factor);
double getSIScaling() const;
bool equal(const Dimension& other);
const std::string& getName() const;
static Dimension * newComposite(const std::string& dim , double SIfactor);

View File

@@ -155,4 +155,16 @@ BOOST_AUTO_TEST_CASE(CreateUnitMap) {
BOOST_CHECK_THROW( systemMap.getSystem( "NoNotThisOne") , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(DimensionEqual) {
Dimension d1("L" , 1);
Dimension d2("L" , 1);
Dimension d3("t" , 1);
Dimension d4("L" , 2);
BOOST_CHECK_EQUAL( true , d1.equal(d1) );
BOOST_CHECK_EQUAL( true , d1.equal(d2) );
BOOST_CHECK_EQUAL( false , d1.equal(d3) );
BOOST_CHECK_EQUAL( false , d1.equal(d4) );
}