[Echempp-devel] Experiment/InputFilters/test inputFiltersTest.cpp, 1.8, 1.9 BAS100B_CV.txt, 1.3, NO
Status: Beta
Brought to you by:
berndspeiser
|
From: beeblbrox <bee...@us...> - 2008-03-27 13:23:06
|
Update of /cvsroot/echempp/Experiment/InputFilters/test In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv15775/Experiment/InputFilters/test Modified Files: inputFiltersTest.cpp Removed Files: BAS100B_CV.txt Log Message: Input filters test files. Index: inputFiltersTest.cpp =================================================================== RCS file: /cvsroot/echempp/Experiment/InputFilters/test/inputFiltersTest.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** inputFiltersTest.cpp 8 Jun 2006 21:44:37 -0000 1.8 --- inputFiltersTest.cpp 27 Mar 2008 13:22:58 -0000 1.9 *************** *** 1,118 **** ! /*! \file inputFiltersTest.cpp ! \brief a test file for InputFilter classes ! ! inputFiltersTest.cpp is part of InputFilters in Experiment ! */ ! ! /* Copyright (C) 2006, Bernd Speiser */ ! /* This file is part of EChem++. ! ! EChem++ is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! EChem++ is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ! 02111-1307, USA. ! */ ! #include "InputFilters/inputFilters.hpp" ! #include "InputFilters/BAS100BinputFilters.hpp" ! #include "Data/data.hpp" ! #include "Data/electrochemicalData.hpp" ! #include <iostream> ! using namespace BSUtilities; ! using namespace inputFilters; ! int main(int argc, const char* argv[]) { ! if (argc > 1) ! { ! if (!strcmp (argv[1], "--version")) { ! std::cout << "InputFilters Test program, " ! << Filter::version () << std::endl; ! exit (0); } ! else { ! std::cout << " usage: InputFiltersTest [--version] " ! << std::endl << " --version: print the InputFilters " ! "version number" ! << std::endl; ! exit (1); } ! } ! ! std::cout << "InputFilter Test program" << std::endl; ! ! std::cout << "=========================================" << std::endl; ! ! std::cout << " testing input from a BAS100B CV data file" ! << std::endl; ! std::string filename ("BAS100B_CV.txt"); ! ! std::cout << " test file name: `" << filename << "'" << std::endl; ! inputFilters::BAS100B<Experiments::CV::RealTT> BAS_CVData; ! std::vector<data::CV::Real> BAS100B_CV_data = ! BAS_CVData.read (filename); ! std::cout << " read " << BAS100B_CV_data.size () << " data sets" ! << std::endl; ! for (unsigned int i = 0; i < BAS100B_CV_data.size (); i++) ! { ! std::cout << " size of set " << i << ": " ! << BAS100B_CV_data[i].size() << std::endl; ! if (BAS100B_CV_data[i].size() >= 10) { ! std::cout << " print first 10 data points:" << std::endl; ! ! for (unsigned int j = 0; j < 10; j++) ! { ! std::cout << " datapoint " << j ! << ": time = " << BAS100B_CV_data[i].getIndependentValue (j) ! << " potential = " ! << BAS100B_CV_data[i].getDependentValue (j) ! << " current = " << BAS100B_CV_data[i].getResponseValue (j) ! << std::endl; ! } } ! } ! ! std::cout << std::endl; ! ! try { ! filename = "unknown.txt"; ! std::cout << " testing incorrect file name: `" ! << filename << "'" << std::endl; ! inputFilters::BAS100B<Experiments::CV::RealTT> BAS_CVDatatest; ! std::vector<data::CV::Real> BAS100B_CV_datatest = ! BAS_CVData.read (filename); ! } ! catch (FileError error) ! { ! std::cout << " caught expected " ! "InputFilters::FileError" ! " exception!!" << std::endl << ! " " << error.message () << std::endl;; - } ! std::cout << std::endl; ! std::cout << "=========================================" << std::endl; ! std::cout << "end of test program for InputFilter classes" ! << std::endl; ! exit (0); } --- 1,92 ---- ! #include <iostream> ! #include <fstream> ! // Boost includes ! #include <boost/test/unit_test.hpp> ! using namespace boost::unit_test; ! #include <boost/archive/tmpdir.hpp> ! #include <boost/tuple/tuple.hpp> ! // Local includes ! #include "../InputFilters.hpp" ! void dump_bas_cond_data(experiment::Experiment* ep) ! { ! experiment::ConditionDataBAS* cd = ! dynamic_cast<experiment::ConditionDataBAS*>(ep->get_cond_data()); ! std::cout << "cd->date = " << cd->date << std::endl; ! std::cout << "cd->time = " << cd->time << std::endl; ! std::cout << "cd->label = " << cd->label << std::endl; ! std::cout << "cd->initE = " << cd->initE << std::endl; ! std::cout << "cd->highE = " << cd->highE << std::endl; ! std::cout << "cd->lowE = " << cd->lowE << std::endl; ! std::cout << "cd->finalE = " << cd->finalE << std::endl; ! std::cout << "cd->pn = " << cd->pn << std::endl; ! std::cout << "cd->v = " << cd->v << std::endl; ! std::cout << "cd->num_segments = " << cd->num_segments << std::endl; ! std::cout << "cd->sample_interval = " << cd->sample_interval << std::endl; ! std::cout << "cd->num_steps = " << cd->num_steps << std::endl; ! std::cout << "cd->R = " << cd->R << std::endl; ! std::cout << "cd->pulse_width = " << cd->pulse_width << std::endl; ! std::cout << "cd->quiet_time = " << cd->quiet_time << std::endl; ! std::cout << "cd->sensitivity = " << cd->sensitivity << std::endl; ! } ! void test_read_bas() { ! experiment::InputFilters ipf; ! experiment::Experiment* ep = ipf.read("examples/m03v01c.txt"); ! std::cout << "ep = " << ep << std::endl; ! experiment::MeasurementDataBase* md = ! dynamic_cast<experiment::MeasurementDataBase*>(ep->get_meas_data()); ! for(unsigned int i=0; i<md->size_i(); ++i) { ! boost::tuple<double,double,double> p = md->get_values(i); ! std::cout << p.get<0>() << " " << p.get<1>() << " " << p.get<2>() << std::endl; } + dump_bas_cond_data(ep); ! ep = ipf.read("examples/bas_ca.txt"); ! std::cout << "ep = " << ep << std::endl; ! md = dynamic_cast<experiment::MeasurementDataBase*>(ep->get_meas_data()); ! for(unsigned int i=0; i<md->size_i(); ++i) { ! boost::tuple<double,double,double> p = md->get_values(i); ! std::cout << p.get<0>() << " " << p.get<1>() << " " << p.get<2>() << std::endl; } ! dump_bas_cond_data(ep); ! ep = ipf.read("examples/dif003.txt"); ! std::cout << "ep = " << ep << std::endl; ! md = dynamic_cast<experiment::MeasurementDataBase*>(ep->get_meas_data()); ! for(unsigned int i=0; i<md->size_i(); ++i) { ! boost::tuple<double,double,double> p = md->get_values(i); ! std::cout << p.get<0>() << " " << p.get<1>() << " " << p.get<2>() << std::endl; } ! dump_bas_cond_data(ep); ! ! } ! void test_read_ascii() ! { ! experiment::InputFilters ipf; ! experiment::Experiment* ep = ipf.read("examples/ascii.txt"); ! std::cout << "ep = " << ep << std::endl; ! experiment::MeasurementDataBase* md = dynamic_cast<experiment::MeasurementDataBase*>(ep->get_meas_data()); ! for(unsigned int i=0; i<md->size_i(); ++i) ! { ! boost::tuple<double,double,double> p = md->get_values(i); ! std::cout << p.get<0>() << " " << p.get<1>() << " " << p.get<2>() << std::endl; ! } ! } + test_suite* + init_unit_test_suite( int argc, char * argv[] ) { + test_suite* test= BOOST_TEST_SUITE( "Input filters unit test" ); + test->add(BOOST_TEST_CASE( &test_read_bas ) ); + test->add(BOOST_TEST_CASE( &test_read_ascii ) ); + return test; } --- BAS100B_CV.txt DELETED --- |