Unit test ThermoPhase::getElementPotentials and setElementPotentials.
This commit is contained in:
parent
d983660c77
commit
e7a24f7acd
1 changed files with 49 additions and 0 deletions
49
test/thermo/ThermoPhase_Test.cpp
Normal file
49
test/thermo/ThermoPhase_Test.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "cantera/thermo/ThermoPhase.h"
|
||||
#include <vector>
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
class ThermoPhase_Fixture : public testing::Test
|
||||
{
|
||||
protected:
|
||||
ThermoPhase test_phase;
|
||||
public:
|
||||
ThermoPhase_Fixture() {}
|
||||
|
||||
~ThermoPhase_Fixture() {}
|
||||
|
||||
void initializeElements()
|
||||
{
|
||||
test_phase.addElement("A", 1.);
|
||||
test_phase.addElement("B", 2.);
|
||||
test_phase.addElement("C", 3.);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ThermoPhase_Fixture, SetAndGetElementPotentials)
|
||||
{
|
||||
initializeElements();
|
||||
|
||||
// Check that getElementPotentials returns false if no element potentials have been set yet.
|
||||
std::vector<double> getLambda(3);
|
||||
EXPECT_FALSE(test_phase.getElementPotentials(&getLambda[0]));
|
||||
|
||||
std::vector<double> tooSmall(2);
|
||||
EXPECT_THROW(test_phase.setElementPotentials(tooSmall), CanteraError);
|
||||
|
||||
std::vector<double> setLambda(3);
|
||||
setLambda[0] = 1.;
|
||||
setLambda[1] = 2.;
|
||||
setLambda[2] = 3.;
|
||||
test_phase.setElementPotentials(setLambda);
|
||||
|
||||
EXPECT_TRUE(test_phase.getElementPotentials(&getLambda[0]));
|
||||
EXPECT_DOUBLE_EQ(setLambda[0], getLambda[0]);
|
||||
EXPECT_DOUBLE_EQ(setLambda[1], getLambda[1]);
|
||||
EXPECT_DOUBLE_EQ(setLambda[2], getLambda[2]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Add table
Reference in a new issue