mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
moved list_components from class_main.cpp to Phreeqc.cpp
git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/branches/class@4173 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
0ec28bc18a
commit
745917b89d
@ -3,6 +3,7 @@
|
||||
|
||||
#include "IPhreeqcCallbacks.h" /* PFN_PRERUN_CALLBACK, PFN_POSTRUN_CALLBACK, PFN_CATCH_CALLBACK */
|
||||
#include "Var.h" /* VRESULT */
|
||||
#include <list>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
@ -551,6 +552,39 @@ int GetErrorLineCount(void);
|
||||
*/
|
||||
const char* GetErrorLine(int n);
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION GetErrorLineCount
|
||||
* INTEGER :: GetErrorLineCount
|
||||
* END FUNCTION GetErrorLineCount
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetComponentCount(void);
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION GetErrorLineCount
|
||||
* INTEGER :: GetErrorLineCount
|
||||
* END FUNCTION GetErrorLineCount
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
const char* GetComponent(int n);
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(WIN32)
|
||||
void DebugOutputLines(void);
|
||||
#endif
|
||||
|
||||
@ -180,6 +180,32 @@ GetErrorLine(int n)
|
||||
return IPhreeqc::LibraryInstance()->GetErrorLine(n);
|
||||
}
|
||||
|
||||
int
|
||||
GetComponentCount(void)
|
||||
{
|
||||
return (int)IPhreeqc::LibraryInstance()->ListComponents().size();
|
||||
}
|
||||
|
||||
const char*
|
||||
GetComponent(int n)
|
||||
{
|
||||
static const char empty[] = "";
|
||||
static std::string comp;
|
||||
std::list< std::string > comps = IPhreeqc::LibraryInstance()->ListComponents();
|
||||
if (n < 0 || n >= (int)comps.size())
|
||||
{
|
||||
return empty;
|
||||
}
|
||||
std::list< std::string >::iterator it = comps.begin();
|
||||
for(int i = 0; i < n; ++i)
|
||||
{
|
||||
++it;
|
||||
}
|
||||
comp = (*it);
|
||||
return comp.c_str();
|
||||
}
|
||||
|
||||
|
||||
IPhreeqc::IPhreeqc(void)
|
||||
: Phreeqc()
|
||||
, ErrorReporter(0)
|
||||
@ -1787,3 +1813,9 @@ void IPhreeqc::update_errors(void)
|
||||
this->ErrorLines.push_back(line);
|
||||
}
|
||||
}
|
||||
std::list< std::string > IPhreeqc::ListComponents(void)
|
||||
{
|
||||
std::list< std::string > comps;
|
||||
this->list_components(comps);
|
||||
return comps;
|
||||
}
|
||||
|
||||
@ -35,6 +35,8 @@ public:
|
||||
int GetErrorLineCount(void)const;
|
||||
const char* GetErrorLine(int n);
|
||||
|
||||
std::list< std::string > ListComponents(void);
|
||||
|
||||
VRESULT AccumulateLine(const char *line);
|
||||
|
||||
void SetDumpOn(bool bValue);
|
||||
|
||||
@ -1692,3 +1692,55 @@ TestInterface::TestGetDumpLine()
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(::GetDumpLine(-3)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(::GetDumpLine(-4)) );
|
||||
}
|
||||
|
||||
void
|
||||
TestInterface::TestGetComponentCount(void)
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( 0, ::LoadDatabase("phreeqc.dat") );
|
||||
|
||||
// add solution block
|
||||
CPPUNIT_ASSERT_EQUAL( VR_OK, SOLUTION(1.0, 1.0, 1.0) );
|
||||
|
||||
// run
|
||||
::SetOutputOn(0);
|
||||
::SetErrorOn(0);
|
||||
::SetLogOn(0);
|
||||
::SetSelectedOutputOn(0);
|
||||
::SetDumpOn(0);
|
||||
::SetDumpStringOn(0);
|
||||
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
|
||||
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 4, ::GetComponentCount() );
|
||||
}
|
||||
|
||||
void
|
||||
TestInterface::TestGetComponent(void)
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( 0, ::LoadDatabase("phreeqc.dat") );
|
||||
|
||||
// add solution block
|
||||
CPPUNIT_ASSERT_EQUAL( VR_OK, SOLUTION(1.0, 1.0, 1.0) );
|
||||
|
||||
// run
|
||||
::SetOutputOn(1);
|
||||
::SetErrorOn(0);
|
||||
::SetLogOn(0);
|
||||
::SetSelectedOutputOn(0);
|
||||
::SetDumpOn(0);
|
||||
::SetDumpStringOn(0);
|
||||
|
||||
std::cout << "\n";
|
||||
::OutputLines();
|
||||
std::cout << "\n";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
|
||||
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 4, ::GetComponentCount() );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("Ca"), std::string(::GetComponent(0)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("H"), std::string(::GetComponent(1)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("Na"), std::string(::GetComponent(2)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("O"), std::string(::GetComponent(3)) );
|
||||
}
|
||||
|
||||
@ -38,6 +38,8 @@ class TestInterface :
|
||||
CPPUNIT_TEST( TestDumpString );
|
||||
CPPUNIT_TEST( TestGetDumpLineCount );
|
||||
CPPUNIT_TEST( TestGetDumpLine );
|
||||
CPPUNIT_TEST( TestGetComponentCount );
|
||||
CPPUNIT_TEST( TestGetComponent );
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
@ -46,35 +48,37 @@ public:
|
||||
~TestInterface(void);
|
||||
|
||||
public:
|
||||
void TestLoadDatabase();
|
||||
void TestLoadDatabaseString();
|
||||
void TestLoadDatabaseMissingFile();
|
||||
void TestLoadDatabaseWithErrors();
|
||||
void TestRun();
|
||||
void TestRunWithErrors();
|
||||
void TestRunFile();
|
||||
void TestGetSelectedOutputRowCount();
|
||||
void TestGetSelectedOutputValue();
|
||||
void TestGetSelectedOutputColumnCount();
|
||||
void TestAddError();
|
||||
void TestAccumulateLine();
|
||||
void TestOutputLastError();
|
||||
void TestRunWithCallback();
|
||||
void TestRunNoDatabaseLoaded();
|
||||
void TestRunFileNoDatabaseLoaded();
|
||||
void TestCase1();
|
||||
void TestCase2();
|
||||
void TestPrintSelectedOutputFalse();
|
||||
void TestOutputOnOff();
|
||||
void TestErrorOnOff();
|
||||
void TestLogOnOff();
|
||||
void TestSelOutOnOff();
|
||||
void TestLongHeadings();
|
||||
void TestDatabaseKeyword();
|
||||
void TestDumpOn();
|
||||
void TestDumpString();
|
||||
void TestGetDumpLineCount();
|
||||
void TestGetDumpLine();
|
||||
void TestLoadDatabase(void);
|
||||
void TestLoadDatabaseString(void);
|
||||
void TestLoadDatabaseMissingFile(void);
|
||||
void TestLoadDatabaseWithErrors(void);
|
||||
void TestRun(void);
|
||||
void TestRunWithErrors(void);
|
||||
void TestRunFile(void);
|
||||
void TestGetSelectedOutputRowCount(void);
|
||||
void TestGetSelectedOutputValue(void);
|
||||
void TestGetSelectedOutputColumnCount(void);
|
||||
void TestAddError(void);
|
||||
void TestAccumulateLine(void);
|
||||
void TestOutputLastError(void);
|
||||
void TestRunWithCallback(void);
|
||||
void TestRunNoDatabaseLoaded(void);
|
||||
void TestRunFileNoDatabaseLoaded(void);
|
||||
void TestCase1(void);
|
||||
void TestCase2(void);
|
||||
void TestPrintSelectedOutputFalse(void);
|
||||
void TestOutputOnOff(void);
|
||||
void TestErrorOnOff(void);
|
||||
void TestLogOnOff(void);
|
||||
void TestSelOutOnOff(void);
|
||||
void TestLongHeadings(void);
|
||||
void TestDatabaseKeyword(void);
|
||||
void TestDumpOn(void);
|
||||
void TestDumpString(void);
|
||||
void TestGetDumpLineCount(void);
|
||||
void TestGetDumpLine(void);
|
||||
void TestGetComponentCount(void);
|
||||
void TestGetComponent(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user