|
[yoda-svn] r327 - in trunk/tests: . Histo1Dblackhole at projects.hepforge.org blackhole at projects.hepforge.orgMon Aug 22 17:39:31 BST 2011
Author: mkawalec Date: Mon Aug 22 17:39:30 2011 New Revision: 327 Log: Added a first test in a series that is intended to provide a multitude of in-depth automatic tests of every function of YODA. Added: trunk/tests/Histo1D/ trunk/tests/Histo1D/Constructors.cc Modified: trunk/tests/Makefile.am Added: trunk/tests/Histo1D/Constructors.cc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/tests/Histo1D/Constructors.cc Mon Aug 22 17:39:30 2011 (r327) @@ -0,0 +1,77 @@ +#include "YODA/Histo1D.h" +#include "YODA/Utils/MathUtils.h" + +#include <iostream> +#include <cmath> + +using namespace YODA; +using namespace std; + +int main() { + cout << "--------------------" << endl; + cout << "Testing constructors: " << endl; + + cout << "The most basic, linear constructor. "; + Histo1D h(100, 0, 100); + if(h.numBins() != 100) { + cout << "FAIL" << endl << "Wrong number of bins was created!" << endl; + return -1; + } + if(h.lowEdge() != 0) { + cout << "FAIL" << endl << "Low edge wasn't properly set!" << endl; + return -1; + } + if(h.highEdge() != 100) { + cout << "FAIL" << endl << "High edge wasn't properly set!" << endl; + return -1; + } + if(!fuzzyEquals(h.integral(), 0)) { + cout << "FAIL" << endl << "The constructor is setting some statistics!" << endl; + return -1; + } + cout << "PASS" << endl; + + cout << "Explitit bin edges constructor: "; + vector<double> edges; + for(int i = 0; i < 101; ++i) edges.push_back(i); + Histo1D h1(edges); + if(h1.numBins() != 100) { + cout << "FAIL" << endl << "Wrong number of bins was created!" << endl; + return -1; + } + if(h1.lowEdge() != 0) { + cout << "FAIL" << endl << "Low edge wasn't properly set!" << endl; + return -1; + } + if(h1.highEdge() != 100) { + cout << "FAIL" << endl << "High edge wasn't properly set!" << endl; + return -1; + } + if(!fuzzyEquals(h1.integral(), 0)) { + cout << "FAIL" << endl << "The constructor is setting some statistics!" << endl; + return -1; + } + cout << "PASS" << endl; + + cout << "Copy constructor: "; + Histo1D h2(h); + if(h2.numBins() != 100) { + cout << "FAIL" << endl << "Wrong number of bins was created!" << endl; + return -1; + } + if(h2.lowEdge() != 0) { + cout << "FAIL" << endl << "Low edge wasn't properly set!" << endl; + return -1; + } + if(h2.highEdge() != 100) { + cout << "FAIL" << endl << "High edge wasn't properly set!" << endl; + return -1; + } + if(!fuzzyEquals(h2.integral(), 0)) { + cout << "FAIL" << endl << "The constructor is setting some statistics!" << endl; + return -1; + } + cout << "PASS" << endl; + + return EXIT_SUCCESS; +} Modified: trunk/tests/Makefile.am ============================================================================== --- trunk/tests/Makefile.am Mon Aug 22 17:02:59 2011 (r326) +++ trunk/tests/Makefile.am Mon Aug 22 17:39:30 2011 (r327) @@ -7,7 +7,8 @@ testhisto2De \ testpoint3D \ testscatter3D\ - testindexedset testsortedvector + testindexedset testsortedvector\ + histo1Dconstructor AM_CPPFLAGS = -I$(top_srcdir)/include AM_LDFLAGS = -L$(top_builddir)/src -lYODA @@ -23,6 +24,7 @@ testhisto2De_SOURCES = TestHisto2Derase.cc testpoint3D_SOURCES = TestPoint3D.cc testscatter3D_SOURCES = TestScatter3D.cc +histo1Dconstructor_SOURCES = Histo1D/Constructors.cc # TODO: Search paths are still not complete for the Python tests: need to add the lib.linux-i686-2.7 part to PYTHONPATH TESTS_ENVIRONMENT = \ @@ -40,4 +42,5 @@ testpoint3D \ testscatter3D \ testindexedset testsortedvector \ - test-yoda-1.py test-yoda-2.py + test-yoda-1.py test-yoda-2.py \ + histo1Dconstructor
More information about the yoda-svn mailing list |