|
[yoda-svn] r341 - in trunk/tests: . Histo1Dblackhole at projects.hepforge.org blackhole at projects.hepforge.orgWed Aug 24 11:30:31 BST 2011
Author: mkawalec Date: Wed Aug 24 11:30:30 2011 New Revision: 341 Log: Added a fill test. Added: trunk/tests/Histo1D/Fill.cc Modified: trunk/tests/Makefile.am Added: trunk/tests/Histo1D/Fill.cc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/tests/Histo1D/Fill.cc Wed Aug 24 11:30:30 2011 (r341) @@ -0,0 +1,47 @@ +#include "YODA/Histo1D.h" + +#include <iostream> +using namespace std; +using namespace YODA; + +int main() { + /// Creating a histo: + Histo1D h(100, 0, 100); + + cout << "Trying to fill the sample histogram: "; + h.fill(0.5,2); + cout << "PASS" << endl; + + cout << "Checking sumW: "; + if(h.sumW() != 2) { + cout << "FAIL" << endl; + return -1; + } + cout << "PASS" << endl; + + cout << "Checking sumW2: "; + if(h.sumW2() != 4) { + cout << "FAIL" << endl; + return -1; + } + cout << "PASS" << endl; + + + h.fill(10, 1); + + cout << "Checking mean: "; + if(!fuzzyEquals(3.66667, h.mean(false))) { + cout << "FAIL" << endl; + return -1; + } + cout << "PASS" << endl; + + cout << "Checking variance: "; + if(!fuzzyEquals(20.0556, h.variance(false))){ + cout << "FAIL" << endl; + return -1; + } + cout << "PASS" << endl; + + return EXIT_SUCCESS; +} Modified: trunk/tests/Makefile.am ============================================================================== --- trunk/tests/Makefile.am Tue Aug 23 16:29:55 2011 (r340) +++ trunk/tests/Makefile.am Wed Aug 24 11:30:30 2011 (r341) @@ -8,7 +8,8 @@ testpoint3D \ testscatter3D\ testindexedset testsortedvector\ - testhisto1Dconstructor + testhisto1Dconstructor \ + testhisto1Dfill AM_CPPFLAGS = -I$(top_srcdir)/include AM_LDFLAGS = -L$(top_builddir)/src -lYODA @@ -25,6 +26,7 @@ testpoint3D_SOURCES = TestPoint3D.cc testscatter3D_SOURCES = TestScatter3D.cc testhisto1Dconstructor_SOURCES = Histo1D/Constructors.cc +testhisto1Dfill_SOURCES = Histo1D/Fill.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 = \ @@ -43,4 +45,5 @@ testscatter3D \ testindexedset testsortedvector \ testhisto1Dconstructor \ + testhisto1Dfill \ test-yoda-1.py test-yoda-2.py
More information about the yoda-svn mailing list |