mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
Fixed small memory leak and updated unit tests for DumpString
git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@5003 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
7a50c36ae8
commit
181868693f
@ -61,6 +61,9 @@ IPhreeqc::IPhreeqc(void)
|
||||
IPhreeqc::~IPhreeqc(void)
|
||||
{
|
||||
delete this->PhreeqcPtr;
|
||||
delete this->SelectedOutput;
|
||||
delete this->WarningReporter;
|
||||
delete this->ErrorReporter;
|
||||
}
|
||||
|
||||
VRESULT IPhreeqc::AccumulateLine(const char *line)
|
||||
|
||||
@ -1606,7 +1606,12 @@ void TestIPhreeqc::TestDumpString()
|
||||
" H(0) -25.15\n"
|
||||
" Na -3.0255625287599\n"
|
||||
" O(0) -42.080044167952\n"
|
||||
" -gammas\n";
|
||||
" -gammas\n"
|
||||
"USE mix none\n"
|
||||
"USE reaction none\n"
|
||||
"USE reaction_temperature none\n"
|
||||
;
|
||||
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
"SOLUTION_RAW 1 \n"
|
||||
@ -1634,7 +1639,11 @@ void TestIPhreeqc::TestDumpString()
|
||||
" H(0) -25.15\n"
|
||||
" Na -3.0255625287599\n"
|
||||
" O(0) -42.080044167952\n"
|
||||
" -gammas\n";
|
||||
" -gammas\n"
|
||||
"USE mix none\n"
|
||||
"USE reaction none\n"
|
||||
"USE reaction_temperature none\n"
|
||||
;
|
||||
#endif
|
||||
|
||||
const char* dump_str = obj.GetDumpString();
|
||||
@ -1663,7 +1672,7 @@ void TestIPhreeqc::TestGetDumpStringLineCount(void)
|
||||
obj.SetDumpStringOn(true);
|
||||
CPPUNIT_ASSERT_EQUAL( true, obj.GetDumpStringOn() );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, obj.RunAccumulated() );
|
||||
CPPUNIT_ASSERT_EQUAL( 26, obj.GetDumpStringLineCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 29, obj.GetDumpStringLineCount() );
|
||||
}
|
||||
|
||||
void TestIPhreeqc::TestGetDumpStringLine(void)
|
||||
@ -1689,7 +1698,7 @@ void TestIPhreeqc::TestGetDumpStringLine(void)
|
||||
obj.SetDumpStringOn(true);
|
||||
CPPUNIT_ASSERT_EQUAL( true, obj.GetDumpStringOn() );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, obj.RunAccumulated() );
|
||||
CPPUNIT_ASSERT_EQUAL( 26, obj.GetDumpStringLineCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 29, obj.GetDumpStringLineCount() );
|
||||
|
||||
int line = 0;
|
||||
#if defined(_MSC_VER)
|
||||
@ -1719,6 +1728,9 @@ void TestIPhreeqc::TestGetDumpStringLine(void)
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" Na -3.0255625287599"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" O(0) -42.080044167952"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" -gammas"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE mix none"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE reaction none"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE reaction_temperature none"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
@ -1748,6 +1760,9 @@ void TestIPhreeqc::TestGetDumpStringLine(void)
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" Na -3.0255625287599"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" O(0) -42.080044167952"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" -gammas"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE mix none"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE reaction none"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE reaction_temperature none"), std::string(obj.GetDumpStringLine(line++)) );
|
||||
#endif
|
||||
|
||||
// remaining lines should be empty
|
||||
|
||||
@ -1717,7 +1717,11 @@ void TestIPhreeqcLib::TestDumpString()
|
||||
" H(0) -25.15\n"
|
||||
" Na -3.0255625287599\n"
|
||||
" O(0) -42.080044167952\n"
|
||||
" -gammas\n";
|
||||
" -gammas\n"
|
||||
"USE mix none\n"
|
||||
"USE reaction none\n"
|
||||
"USE reaction_temperature none\n"
|
||||
;
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
"SOLUTION_RAW 1 \n"
|
||||
@ -1745,7 +1749,11 @@ void TestIPhreeqcLib::TestDumpString()
|
||||
" H(0) -25.15\n"
|
||||
" Na -3.0255625287599\n"
|
||||
" O(0) -42.080044167952\n"
|
||||
" -gammas\n";
|
||||
" -gammas\n"
|
||||
"USE mix none\n"
|
||||
"USE reaction none\n"
|
||||
"USE reaction_temperature none\n"
|
||||
;
|
||||
#endif
|
||||
|
||||
const char* dump_str = ::GetDumpString(n);
|
||||
@ -1778,7 +1786,7 @@ void TestIPhreeqcLib::TestGetDumpStringLineCount(void)
|
||||
CPPUNIT_ASSERT_EQUAL( IPQ_OK, ::SetDumpFileOn(n, 0) );
|
||||
CPPUNIT_ASSERT_EQUAL( IPQ_OK, ::SetDumpStringOn(n, 1) );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, ::RunAccumulated(n) );
|
||||
CPPUNIT_ASSERT_EQUAL( 26, ::GetDumpStringLineCount(n) );
|
||||
CPPUNIT_ASSERT_EQUAL( 29, ::GetDumpStringLineCount(n) );
|
||||
|
||||
if (n >= 0)
|
||||
{
|
||||
@ -1807,7 +1815,7 @@ void TestIPhreeqcLib::TestGetDumpStringLine(void)
|
||||
CPPUNIT_ASSERT_EQUAL( IPQ_OK, ::SetDumpFileOn(n, 0) );
|
||||
CPPUNIT_ASSERT_EQUAL( IPQ_OK, ::SetDumpStringOn(n, 1) );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, ::RunAccumulated(n) );
|
||||
CPPUNIT_ASSERT_EQUAL( 26, ::GetDumpStringLineCount(n) );
|
||||
CPPUNIT_ASSERT_EQUAL( 29, ::GetDumpStringLineCount(n) );
|
||||
|
||||
int line = 0;
|
||||
#if defined(_MSC_VER)
|
||||
@ -1837,6 +1845,9 @@ void TestIPhreeqcLib::TestGetDumpStringLine(void)
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" Na -3.0255625287599"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" O(0) -42.080044167952"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" -gammas"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE mix none"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE reaction none"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE reaction_temperature none"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
@ -1866,6 +1877,9 @@ void TestIPhreeqcLib::TestGetDumpStringLine(void)
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" Na -3.0255625287599"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" O(0) -42.080044167952"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string(" -gammas"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE mix none"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE reaction none"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
CPPUNIT_ASSERT_EQUAL( std::string("USE reaction_temperature none"), std::string(::GetDumpStringLine(n, line++)) );
|
||||
#endif
|
||||
|
||||
// remaining lines should be empty
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user