iphreeqc/classes/TestCIsotope.cxx
David L Parkhurst 60a1544019 Copying new classes (cxx) and cpp files to src
Will remove cpp and header files and make phreeqc an external directory.




git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@785 1feff8c3-07ed-0310-ac33-dd36852eb9cd
2006-02-16 00:21:39 +00:00

165 lines
4.5 KiB
C++

#include "TestCIsotope.h"
#include "Parser.h"
#include "utilities.h"
TestCIsotope::TestCIsotope()
{
}
TestCIsotope::~TestCIsotope()
{
}
void TestCIsotope::test_read_1()
{
CIsotope iso;
std::ostringstream oss_out;
std::ostringstream oss_err;
std::istringstream::pos_type next_pos;
std::vector<std::string> opt_list;
std::istringstream iss_in("-isotope");
CParser parser(iss_in, oss_out, oss_err);
opt_list.push_back("isotope");
CPPUNIT_ASSERT(parser.get_option(opt_list, next_pos) == 0);
CPPUNIT_ASSERT(iso.read(parser) == CIsotope::ERROR);
CPPUNIT_ASSERT(oss_err.str().compare("ERROR: Expected isotope name to begin with an isotopic number.\n") == 0);
}
void TestCIsotope::test_read_2()
{
CIsotope iso;
std::ostringstream oss_out;
std::ostringstream oss_err;
std::istringstream::pos_type next_pos;
std::vector<std::string> opt_list;
std::istringstream iss_in("-isotope C");
CParser parser(iss_in, oss_out, oss_err);
opt_list.push_back("isotope");
CPPUNIT_ASSERT(parser.get_option(opt_list, next_pos) == 0);
CPPUNIT_ASSERT(iso.read(parser) == CIsotope::ERROR);
CPPUNIT_ASSERT(oss_err.str().compare("ERROR: Expected isotope name to begin with an isotopic number.\n") == 0);
}
void TestCIsotope::test_read_3()
{
CIsotope iso;
std::ostringstream oss_out;
std::ostringstream oss_err;
std::istringstream::pos_type next_pos;
std::vector<std::string> opt_list;
std::istringstream iss_in("isotope 13");
CParser parser(iss_in, oss_out, oss_err);
opt_list.push_back("isotope");
CPPUNIT_ASSERT(parser.get_option(opt_list, next_pos) == 0);
CPPUNIT_ASSERT(iso.read(parser) == CIsotope::ERROR);
CPPUNIT_ASSERT(oss_err.str().compare("ERROR: Expecting element name.\nERROR: isotope 13\n") == 0);
}
void TestCIsotope::test_read_4()
{
CIsotope iso;
std::ostringstream oss_out;
std::ostringstream oss_err;
std::istringstream::pos_type next_pos;
std::vector<std::string> opt_list;
std::istringstream iss_in("isotope 13C");
CParser parser(iss_in, oss_out, oss_err);
opt_list.push_back("isotope");
CPPUNIT_ASSERT(parser.get_option(opt_list, next_pos) == 0);
CPPUNIT_ASSERT(iso.read(parser) == CIsotope::ERROR);
CPPUNIT_ASSERT(oss_err.str().compare("ERROR: Expected numeric value for isotope ratio.\n") == 0);
}
void TestCIsotope::test_read_5()
{
CIsotope iso;
std::ostringstream oss_out;
std::ostringstream oss_err;
std::istringstream::pos_type next_pos;
std::vector<std::string> opt_list;
std::istringstream iss_in("isotope 13C -");
CParser parser(iss_in, oss_out, oss_err);
opt_list.push_back("isotope");
CPPUNIT_ASSERT(parser.get_option(opt_list, next_pos) == 0);
CPPUNIT_ASSERT(iso.read(parser) == CIsotope::ERROR);
CPPUNIT_ASSERT(oss_err.str().compare("ERROR: Expected numeric value for isotope ratio.\n") == 0);
}
void TestCIsotope::test_read_6()
{
CIsotope iso;
std::ostringstream oss_out;
std::ostringstream oss_err;
std::istringstream::pos_type next_pos;
std::vector<std::string> opt_list;
std::istringstream iss_in("isotope 13C -12.");
CParser parser(iss_in, oss_out, oss_err);
opt_list.push_back("isotope");
CPPUNIT_ASSERT(parser.get_option(opt_list, next_pos) == 0);
CPPUNIT_ASSERT(iso.read(parser) == CIsotope::OK);
CPPUNIT_ASSERT(oss_err.str().empty());
CPPUNIT_ASSERT(iso.get_name().compare("13C") == 0);
CPPUNIT_ASSERT(iso.get_ratio() == -12.0);
CPPUNIT_ASSERT(!iso.get_ratio_uncertainty_defined());
}
void TestCIsotope::test_read_7()
{
CIsotope iso;
std::ostringstream oss_out;
std::ostringstream oss_err;
std::istringstream::pos_type next_pos;
std::vector<std::string> opt_list;
std::istringstream iss_in("isotope 13C -12. a");
CParser parser(iss_in, oss_out, oss_err);
opt_list.push_back("isotope");
CPPUNIT_ASSERT(parser.get_option(opt_list, next_pos) == 0);
CPPUNIT_ASSERT(iso.read(parser) == CIsotope::ERROR);
CPPUNIT_ASSERT(oss_err.str().compare("ERROR: Expected numeric value for uncertainty in isotope ratio.\n") == 0);
}
void TestCIsotope::test_read_8()
{
CIsotope iso;
std::ostringstream oss_out;
std::ostringstream oss_err;
std::istringstream::pos_type next_pos;
std::vector<std::string> opt_list;
std::istringstream iss_in("isotope 13C -12. 1.");
CParser parser(iss_in, oss_out, oss_err);
opt_list.push_back("isotope");
CPPUNIT_ASSERT(parser.get_option(opt_list, next_pos) == 0);
CPPUNIT_ASSERT(iso.read(parser) == CIsotope::OK);
CPPUNIT_ASSERT(oss_err.str().empty());
CPPUNIT_ASSERT(iso.get_name().compare("13C") == 0);
CPPUNIT_ASSERT(iso.get_ratio() == -12.0);
CPPUNIT_ASSERT(iso.get_ratio_uncertainty() == 1.0);
CPPUNIT_ASSERT(iso.get_ratio_uncertainty_defined());
}