mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
Added some additional std::map checking
git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@8288 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
bec792ae89
commit
5086b94ada
@ -1005,22 +1005,26 @@ void IPhreeqc::UnLoadDatabase(void)
|
|||||||
|
|
||||||
int IPhreeqc::EndRow(void)
|
int IPhreeqc::EndRow(void)
|
||||||
{
|
{
|
||||||
if (this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output]->GetRowCount() <= 1)
|
if (this->PhreeqcPtr->current_selected_output)
|
||||||
{
|
{
|
||||||
// ensure all user_punch headings are included
|
std::map< SelectedOutput*, CSelectedOutput* >::iterator it =
|
||||||
ASSERT(this->PhreeqcPtr->n_user_punch_index >= 0);
|
this->CurrentSelectedOutputMap.find(this->PhreeqcPtr->current_selected_output);
|
||||||
if (this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output] != NULL)
|
|
||||||
|
if (it != this->CurrentSelectedOutputMap.end())
|
||||||
{
|
{
|
||||||
|
// ensure all user_punch headings are included
|
||||||
|
ASSERT(this->PhreeqcPtr->n_user_punch_index >= 0);
|
||||||
if (this->PhreeqcPtr->current_user_punch)
|
if (this->PhreeqcPtr->current_user_punch)
|
||||||
{
|
{
|
||||||
for (size_t i = this->PhreeqcPtr->n_user_punch_index; i < this->PhreeqcPtr->current_user_punch->Get_headings().size(); ++i)
|
for (size_t i = this->PhreeqcPtr->n_user_punch_index; i < this->PhreeqcPtr->current_user_punch->Get_headings().size(); ++i)
|
||||||
{
|
{
|
||||||
this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output]->PushBackEmpty(this->PhreeqcPtr->current_user_punch->Get_headings()[i].c_str());
|
(*it).second->PushBackEmpty(this->PhreeqcPtr->current_user_punch->Get_headings()[i].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return (*it).second->EndRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output]->EndRow();
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPhreeqc::check_database(const char* sz_routine)
|
void IPhreeqc::check_database(const char* sz_routine)
|
||||||
@ -1128,6 +1132,10 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, PFN_PRERUN_CALL
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ASSERT(this->SelectedOutputMap.find((*mit).first) != this->SelectedOutputMap.end());
|
||||||
|
ASSERT(this->CurrentSelectedOutputMap.find(&(*mit).second) != this->CurrentSelectedOutputMap.end());
|
||||||
|
ASSERT(this->CurrentToStringMap.find(&(*mit).second) != this->CurrentToStringMap.end());
|
||||||
|
|
||||||
ASSERT(this->SelectedOutputMap[(*mit).first] == this->CurrentSelectedOutputMap[&(*mit).second]);
|
ASSERT(this->SelectedOutputMap[(*mit).first] == this->CurrentSelectedOutputMap[&(*mit).second]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1521,6 +1529,7 @@ void IPhreeqc::punch_msg(const char *str)
|
|||||||
{
|
{
|
||||||
if (this->SelectedOutputStringOn && this->punch_on)
|
if (this->SelectedOutputStringOn && this->punch_on)
|
||||||
{
|
{
|
||||||
|
ASSERT(this->CurrentToStringMap.find(this->PhreeqcPtr->current_selected_output) != this->CurrentToStringMap.end());
|
||||||
*(this->CurrentToStringMap[this->PhreeqcPtr->current_selected_output]) += str;
|
*(this->CurrentToStringMap[this->PhreeqcPtr->current_selected_output]) += str;
|
||||||
}
|
}
|
||||||
ASSERT(!(this->SelectedOutputFileOnMap[this->PhreeqcPtr->current_selected_output->Get_n_user()] != (this->PhreeqcPtr->current_selected_output->Get_punch_ostream() != 0)));
|
ASSERT(!(this->SelectedOutputFileOnMap[this->PhreeqcPtr->current_selected_output->Get_n_user()] != (this->PhreeqcPtr->current_selected_output->Get_punch_ostream() != 0)));
|
||||||
@ -1620,8 +1629,10 @@ void IPhreeqc::fpunchf(const char *name, const char *format, double d)
|
|||||||
this->PHRQ_io::fpunchf(name, format, d);
|
this->PHRQ_io::fpunchf(name, format, d);
|
||||||
if (this->SelectedOutputStringOn && this->punch_on)
|
if (this->SelectedOutputStringOn && this->punch_on)
|
||||||
{
|
{
|
||||||
|
ASSERT(this->CurrentToStringMap.find(this->PhreeqcPtr->current_selected_output) != this->CurrentToStringMap.end());
|
||||||
PHRQ_io::fpunchf_helper(this->CurrentToStringMap[this->PhreeqcPtr->current_selected_output], format, d);
|
PHRQ_io::fpunchf_helper(this->CurrentToStringMap[this->PhreeqcPtr->current_selected_output], format, d);
|
||||||
}
|
}
|
||||||
|
ASSERT(this->CurrentSelectedOutputMap.find(this->PhreeqcPtr->current_selected_output) != this->CurrentSelectedOutputMap.end());
|
||||||
this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output]->PushBackDouble(name, d);
|
this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output]->PushBackDouble(name, d);
|
||||||
}
|
}
|
||||||
catch (std::bad_alloc)
|
catch (std::bad_alloc)
|
||||||
@ -1637,8 +1648,10 @@ void IPhreeqc::fpunchf(const char *name, const char *format, char *s)
|
|||||||
this->PHRQ_io::fpunchf(name, format, s);
|
this->PHRQ_io::fpunchf(name, format, s);
|
||||||
if (this->SelectedOutputStringOn && this->punch_on)
|
if (this->SelectedOutputStringOn && this->punch_on)
|
||||||
{
|
{
|
||||||
|
ASSERT(this->CurrentToStringMap.find(this->PhreeqcPtr->current_selected_output) != this->CurrentToStringMap.end());
|
||||||
PHRQ_io::fpunchf_helper(this->CurrentToStringMap[this->PhreeqcPtr->current_selected_output], format, s);
|
PHRQ_io::fpunchf_helper(this->CurrentToStringMap[this->PhreeqcPtr->current_selected_output], format, s);
|
||||||
}
|
}
|
||||||
|
ASSERT(this->CurrentSelectedOutputMap.find(this->PhreeqcPtr->current_selected_output) != this->CurrentSelectedOutputMap.end());
|
||||||
this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output]->PushBackString(name, s);
|
this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output]->PushBackString(name, s);
|
||||||
}
|
}
|
||||||
catch (std::bad_alloc)
|
catch (std::bad_alloc)
|
||||||
@ -1654,8 +1667,10 @@ void IPhreeqc::fpunchf(const char *name, const char *format, int i)
|
|||||||
this->PHRQ_io::fpunchf(name, format, i);
|
this->PHRQ_io::fpunchf(name, format, i);
|
||||||
if (this->SelectedOutputStringOn && this->punch_on)
|
if (this->SelectedOutputStringOn && this->punch_on)
|
||||||
{
|
{
|
||||||
|
ASSERT(this->CurrentToStringMap.find(this->PhreeqcPtr->current_selected_output) != this->CurrentToStringMap.end());
|
||||||
PHRQ_io::fpunchf_helper(this->CurrentToStringMap[this->PhreeqcPtr->current_selected_output], format, i);
|
PHRQ_io::fpunchf_helper(this->CurrentToStringMap[this->PhreeqcPtr->current_selected_output], format, i);
|
||||||
}
|
}
|
||||||
|
ASSERT(this->CurrentSelectedOutputMap.find(this->PhreeqcPtr->current_selected_output) != this->CurrentSelectedOutputMap.end());
|
||||||
this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output]->PushBackLong(name, (long)i);
|
this->CurrentSelectedOutputMap[this->PhreeqcPtr->current_selected_output]->PushBackLong(name, (long)i);
|
||||||
}
|
}
|
||||||
catch (std::bad_alloc)
|
catch (std::bad_alloc)
|
||||||
|
|||||||
@ -4490,3 +4490,28 @@ void TestIPhreeqcLib::TestWissmeier20131203_3(void)
|
|||||||
CPPUNIT_ASSERT_EQUAL( 1, ::GetSelectedOutputColumnCount(id) );
|
CPPUNIT_ASSERT_EQUAL( 1, ::GetSelectedOutputColumnCount(id) );
|
||||||
CPPUNIT_ASSERT_EQUAL( 2, ::GetSelectedOutputRowCount(id) );
|
CPPUNIT_ASSERT_EQUAL( 2, ::GetSelectedOutputRowCount(id) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestIPhreeqcLib::TestIsZeroInitialized(void)
|
||||||
|
{
|
||||||
|
std::map<void*, void*> test_map;
|
||||||
|
CPPUNIT_ASSERT( test_map.find((void*)0) == test_map.end() );
|
||||||
|
CPPUNIT_ASSERT( test_map[(void*)0] == (void*)0 );
|
||||||
|
|
||||||
|
int i = int();
|
||||||
|
long l = long();
|
||||||
|
float f = float();
|
||||||
|
double d = double();
|
||||||
|
|
||||||
|
// these would fail
|
||||||
|
/**
|
||||||
|
int i;
|
||||||
|
long l;
|
||||||
|
float f;
|
||||||
|
double d;
|
||||||
|
**/
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( (int)0, i );
|
||||||
|
CPPUNIT_ASSERT_EQUAL( (long)0, l );
|
||||||
|
CPPUNIT_ASSERT_EQUAL( (float)0, f );
|
||||||
|
CPPUNIT_ASSERT_EQUAL( (double)0, d );
|
||||||
|
}
|
||||||
|
|||||||
@ -79,6 +79,7 @@ class TestIPhreeqcLib : public CppUnit::TestFixture
|
|||||||
CPPUNIT_TEST( TestWissmeier20131203 );
|
CPPUNIT_TEST( TestWissmeier20131203 );
|
||||||
CPPUNIT_TEST( TestWissmeier20131203_2 );
|
CPPUNIT_TEST( TestWissmeier20131203_2 );
|
||||||
CPPUNIT_TEST( TestWissmeier20131203_3 );
|
CPPUNIT_TEST( TestWissmeier20131203_3 );
|
||||||
|
CPPUNIT_TEST( TestIsZeroInitialized );
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -158,6 +159,7 @@ public:
|
|||||||
void TestWissmeier20131203(void);
|
void TestWissmeier20131203(void);
|
||||||
void TestWissmeier20131203_2(void);
|
void TestWissmeier20131203_2(void);
|
||||||
void TestWissmeier20131203_3(void);
|
void TestWissmeier20131203_3(void);
|
||||||
|
void TestIsZeroInitialized(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void TestFileOnOff(const char* FILENAME, int output_file_on, int error_file_on, int log_file_on, int selected_output_file_on, int dump_file_on);
|
void TestFileOnOff(const char* FILENAME, int output_file_on, int error_file_on, int log_file_on, int selected_output_file_on, int dump_file_on);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user