Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F7877254
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
19 KB
Subscribers
None
View Options
diff --git a/Utilities/Makefile.am b/Utilities/Makefile.am
--- a/Utilities/Makefile.am
+++ b/Utilities/Makefile.am
@@ -1,33 +1,38 @@
SUBDIRS = XML Statistics
noinst_LTLIBRARIES = libHwUtils.la
pkglib_LTLIBRARIES = libHwRunDirectories.la
libHwUtils_la_SOURCES = \
EnumParticles.h \
Interpolator.tcc Interpolator.h \
Kinematics.cc Kinematics.h \
Smearing.cc Smearing.h \
Maths.h Maths.cc \
StandardSelectors.cc StandardSelectors.h\
Histogram.cc Histogram.fh Histogram.h \
GaussianIntegrator.cc GaussianIntegrator.h \
GaussianIntegrator.tcc \
Statistic.h HerwigStrategy.cc HerwigStrategy.h \
GSLIntegrator.h GSLIntegrator.tcc \
GSLBisection.h GSLBisection.tcc GSLHelper.h
libHwRunDirectories_la_SOURCES = \
RunDirectories.h RunDirectories.cc
libHwUtils_la_LIBADD = \
XML/libHwXML.la \
Statistics/libHwStatistics.la
CLEANFILES=
include $(srcdir)/Makefile.am.versionstring
check_PROGRAMS = utilities_test
-utilities_test_SOURCES = tests/utilitiesTests.cc
+utilities_test_SOURCES = \
+tests/utilitiesTestsMain.cc \
+tests/utilitiesTestsGlobalFixture.h \
+tests/utilitiesTestsKinematics.h \
+tests/utilitiesTestsMaths.h \
+tests/utilitiesTestsStatistic.h
utilities_test_LDADD = $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_FILESYSTEM_LIBS) $(BOOST_SYSTEM_LIBS) $(THEPEGLIB) -ldl libHwUtils.la
utilities_test_LDFLAGS = $(AM_LDFLAGS) -export-dynamic $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_FILESYSTEM_LDFLAGS) $(THEPEGLDFLAGS)
utilities_test_CPPFLAGS = $(AM_CPPFLAGS) $(BOOST_CPPFLAGS) -DHERWIG_PKGDATADIR="\"$(pkgdatadir)\"" -DHERWIG_PKGLIBDIR="\"$(pkglibdir)\"" -DTHEPEG_PKGLIBDIR="\"$(THEPEGLIBPATH)\""
TESTS = utilities_test
diff --git a/Utilities/tests/utilitiesTestMaths.h b/Utilities/tests/utilitiesTestMaths.h
new file mode 100644
--- /dev/null
+++ b/Utilities/tests/utilitiesTestMaths.h
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+//
+// utilitiesTestMaths.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2011 The Herwig Collaboration, 2015 Marco A. Harrendorf
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_Utilities_Test_Maths_H
+#define HERWIG_Utilities_Test_Maths_H
+
+#include <boost/test/unit_test.hpp>
+
+#include "Herwig++/Utilities/Maths.h"
+
+/*
+ * Start of boost unit tests for Maths.h
+ *
+ */
+BOOST_AUTO_TEST_SUITE(utilitiesMathsTest)
+
+/*
+ * Boost unit tests
+ *
+ */
+BOOST_AUTO_TEST_CASE(dilogFunction)
+{
+ BOOST_CHECK_EQUAL(Herwig::Math::Li2(0.), 0.);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(-1).real(), -1./12. * M_PI * M_PI, 1e-5);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(-1).imag(), 0., 1e-5);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(1).real(), 1./6. * M_PI * M_PI, 1e-5);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(1).imag(), 0., 1e-5);
+
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(Herwig::Complex(0.5, 1)).real(), 0.203354, 2e-4);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(Herwig::Complex(0.5, 1)).imag(), 1.13194, 1e-4);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(Herwig::Complex(-0.5, -1)).real(), -0.578503, 1e-4);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(Herwig::Complex(-0.5, -1)).imag(), -0.772714, 1e-4);
+}
+
+BOOST_AUTO_TEST_CASE(realDilogFunction)
+{
+ BOOST_CHECK_EQUAL(Herwig::Math::ReLi2(0.), 0.);
+ BOOST_CHECK_CLOSE(Herwig::Math::ReLi2(-1), -1./12. * M_PI * M_PI, 1e-5);
+ BOOST_CHECK_CLOSE(Herwig::Math::ReLi2(1), 1./6. * M_PI * M_PI, 1e-5);
+}
+
+
+BOOST_AUTO_TEST_CASE(angleZeroTo2Pi)
+{
+ BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi(0.), 0.);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi(-0.5*M_PI), 1.5*M_PI);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi(-2.5*M_PI), 1.5*M_PI);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi( 2.5*M_PI), 0.5*M_PI);
+ BOOST_CHECK(Herwig::Math::angleZeroTo2Pi( 2.5*M_PI) != 1*M_PI);
+}
+
+BOOST_AUTO_TEST_CASE(angleMinusPiToPi)
+{
+ BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi(0.), 0.);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi(-0.5*M_PI), -0.5*M_PI);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi(-2.5*M_PI), -0.5*M_PI);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi( 2.5*M_PI), 0.5*M_PI);
+ BOOST_CHECK(Herwig::Math::angleMinusPiToPi( 2.5*M_PI) != 1*M_PI);
+}
+
+BOOST_AUTO_TEST_CASE(median)
+{
+ std::vector<double> medianTest1;
+ medianTest1.push_back(10);
+ medianTest1.push_back(-1);
+ medianTest1.push_back(5);
+ BOOST_CHECK_EQUAL(Herwig::Math::median<double>(medianTest1), 5);
+
+ std::vector<double> medianTest2;
+ medianTest2.push_back(-10);
+ medianTest2.push_back(-1);
+ medianTest2.push_back(-5);
+ medianTest2.push_back(-6);
+ BOOST_CHECK_EQUAL(Herwig::Math::median<double>(medianTest2), -6);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+#endif /* HERWIG_Utilities_Test_Maths_H */
\ No newline at end of file
diff --git a/Utilities/tests/utilitiesTests.cc b/Utilities/tests/utilitiesTests.cc
deleted file mode 100644
--- a/Utilities/tests/utilitiesTests.cc
+++ /dev/null
@@ -1,211 +0,0 @@
-// -*- C++ -*-
-//
-// utilitiesTest.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
-// Copyright (C) 2002-2011 The Herwig Collaboration, 2015 Marco A. Harrendorf
-//
-// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
-// Please respect the MCnet academic guidelines, see GUIDELINES for details.
-//
-
-#define BOOST_TEST_DYN_LINK
-#define BOOST_TEST_MAIN
-#include <boost/test/unit_test.hpp>
-#define BOOST_TEST_MODULE utilitiesTest
-
-
-
-#include "Herwig++/Utilities/Kinematics.h"
-#include "Herwig++/Utilities/Maths.h"
-#include "Herwig++/Utilities/Statistic.h"
-
-#include "ThePEG/Repository/StandardRandom.h"
-#include "ThePEG/Repository/UseRandom.h"
-
-struct FixKinematics1 {
- FixKinematics1()
- {BOOST_TEST_MESSAGE( "setup fixture for utilitiesKinematicsTestTest" ); }
-
- ~FixKinematics1() { BOOST_TEST_MESSAGE( "teardown fixture for utilitiesKinematicsTest" ); }
-};
-
-/*
- * Start of boost unit tests for Kinematics.h
- *
- */
-BOOST_AUTO_TEST_SUITE(utilitiesKinematicsTest)
-
-/*
- * Boost unit tests
- * @todo solve problem with linking to ThePEG library
- */
-
-BOOST_FIXTURE_TEST_CASE(generateAnglestest, FixKinematics1)
-{
- ThePEG::StandardRandom randomNumberStandardGenerator = ThePEG::StandardRandom();
- ThePEG::UseRandom testUseRandom = ThePEG::UseRandom(&randomNumberStandardGenerator);
- double flatMinusPiToPlusPi, flatNullToTwoPi;
- for(int i = 0; i < 100; ++i) {
- Herwig::Kinematics::generateAngles(flatMinusPiToPlusPi, flatNullToTwoPi);
- BOOST_CHECK( -M_PI <= flatMinusPiToPlusPi );
- BOOST_CHECK( flatMinusPiToPlusPi <= M_PI);
- BOOST_CHECK( 0. <= flatNullToTwoPi);
- BOOST_CHECK(flatNullToTwoPi <= 2*M_PI);
- }
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-//____________________________________________________________________________//
-
-/*
- * Start of boost unit tests for Maths.h
- *
- */
-BOOST_AUTO_TEST_SUITE(utilitiesMathsTest)
-
-/*
- * Boost unit tests
- *
- */
-BOOST_AUTO_TEST_CASE(dilogFunction)
-{
- BOOST_CHECK_EQUAL(Herwig::Math::Li2(0.), 0.);
- BOOST_CHECK_CLOSE(Herwig::Math::Li2(-1).real(), -1./12. * M_PI * M_PI, 1e-5);
- BOOST_CHECK_CLOSE(Herwig::Math::Li2(-1).imag(), 0., 1e-5);
- BOOST_CHECK_CLOSE(Herwig::Math::Li2(1).real(), 1./6. * M_PI * M_PI, 1e-5);
- BOOST_CHECK_CLOSE(Herwig::Math::Li2(1).imag(), 0., 1e-5);
-
- BOOST_CHECK_CLOSE(Herwig::Math::Li2(Herwig::Complex(0.5, 1)).real(), 0.203354, 2e-4);
- BOOST_CHECK_CLOSE(Herwig::Math::Li2(Herwig::Complex(0.5, 1)).imag(), 1.13194, 1e-4);
- BOOST_CHECK_CLOSE(Herwig::Math::Li2(Herwig::Complex(-0.5, -1)).real(), -0.578503, 1e-4);
- BOOST_CHECK_CLOSE(Herwig::Math::Li2(Herwig::Complex(-0.5, -1)).imag(), -0.772714, 1e-4);
-}
-
-BOOST_AUTO_TEST_CASE(realDilogFunction)
-{
- BOOST_CHECK_EQUAL(Herwig::Math::ReLi2(0.), 0.);
- BOOST_CHECK_CLOSE(Herwig::Math::ReLi2(-1), -1./12. * M_PI * M_PI, 1e-5);
- BOOST_CHECK_CLOSE(Herwig::Math::ReLi2(1), 1./6. * M_PI * M_PI, 1e-5);
-}
-
-
-BOOST_AUTO_TEST_CASE(angleZeroTo2Pi)
-{
- BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi(0.), 0.);
- BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi(-0.5*M_PI), 1.5*M_PI);
- BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi(-2.5*M_PI), 1.5*M_PI);
- BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi( 2.5*M_PI), 0.5*M_PI);
- BOOST_CHECK(Herwig::Math::angleZeroTo2Pi( 2.5*M_PI) != 1*M_PI);
-}
-
-BOOST_AUTO_TEST_CASE(angleMinusPiToPi)
-{
- BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi(0.), 0.);
- BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi(-0.5*M_PI), -0.5*M_PI);
- BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi(-2.5*M_PI), -0.5*M_PI);
- BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi( 2.5*M_PI), 0.5*M_PI);
- BOOST_CHECK(Herwig::Math::angleMinusPiToPi( 2.5*M_PI) != 1*M_PI);
-}
-
-BOOST_AUTO_TEST_CASE(median)
-{
- std::vector<double> medianTest1;
- medianTest1.push_back(10);
- medianTest1.push_back(-1);
- medianTest1.push_back(5);
- BOOST_CHECK_EQUAL(Herwig::Math::median<double>(medianTest1), 5);
-
- std::vector<double> medianTest2;
- medianTest2.push_back(-10);
- medianTest2.push_back(-1);
- medianTest2.push_back(-5);
- medianTest2.push_back(-6);
- BOOST_CHECK_EQUAL(Herwig::Math::median<double>(medianTest2), -6);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-//____________________________________________________________________________//
-
-/*
- * Fixture which defines the common variables for testing Statistic class
- */
-struct FixStatistic1 {
- FixStatistic1() : statisticDefault(), statisticTest()
- {BOOST_TEST_MESSAGE( "setup fixture for utilitiesStatisticTest" ); }
-
- ~FixStatistic1() { BOOST_TEST_MESSAGE( "teardown fixture for utilitiesStatisticTest" ); }
-
- Herwig::Statistic statisticDefault;
- Herwig::Statistic statisticTest;
-};
-
-/*
- * Start of boost unit tests for Statistic.h
- *
- */
-BOOST_FIXTURE_TEST_SUITE(utilitiesStatisticTest, FixStatistic1 )
-
-/*
- * Boost unit tests
- *
- */
-BOOST_AUTO_TEST_CASE(defaultConstructor)
-{
- BOOST_CHECK_EQUAL(statisticDefault.numberOfPoints(), static_cast<unsigned int>(0));
- BOOST_CHECK_EQUAL(statisticDefault.total(), 0.);
- BOOST_CHECK_EQUAL(statisticDefault.mean(), 0.);
- BOOST_CHECK_EQUAL(statisticDefault.minimum(), -1e100);
- BOOST_CHECK_EQUAL(statisticDefault.maximum(), 1e100);
- BOOST_CHECK_EQUAL(statisticDefault.var(), 0);
- BOOST_CHECK_EQUAL(statisticDefault.mean_var(), 0);
-}
-
-BOOST_AUTO_TEST_CASE(operations)
-{
- statisticTest += 2;
- BOOST_CHECK_EQUAL(statisticTest.minimum(), 2);
- BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
-
- statisticTest += -2;
- BOOST_CHECK_EQUAL(statisticTest.numberOfPoints(), static_cast<unsigned int>(2));
- BOOST_CHECK_EQUAL(statisticTest.total(), 0.);
- BOOST_CHECK_EQUAL(statisticTest.mean(), 0.);
- BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
- BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
- BOOST_CHECK_EQUAL(statisticTest.var(), 8);
- BOOST_CHECK_EQUAL(statisticTest.stdDev(), sqrt(8));
- BOOST_CHECK_EQUAL(statisticTest.mean_var(), 4);
- BOOST_CHECK_EQUAL(statisticTest.mean_stdDev(), 2);
-
- statisticTest += 2;
- BOOST_CHECK_EQUAL(statisticTest.numberOfPoints(), static_cast<unsigned int>(3));
- BOOST_CHECK_EQUAL(statisticTest.total(), 2.);
- BOOST_CHECK_EQUAL(statisticTest.mean(), 2./3.);
- BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
- BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
- BOOST_CHECK_EQUAL(statisticTest.var(), 16./3.);
- BOOST_CHECK_EQUAL(statisticTest.stdDev(), sqrt(16./3.));
- BOOST_CHECK_EQUAL(statisticTest.mean_var(), 16./9.);
- BOOST_CHECK_EQUAL(statisticTest.mean_stdDev(), sqrt(16./9.));
-
- statisticTest += 4.5;
- BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
- BOOST_CHECK_EQUAL(statisticTest.maximum(), 4.5);
-
- statisticTest += -3.5;
- BOOST_CHECK_EQUAL(statisticTest.minimum(), -3.5);
- BOOST_CHECK_EQUAL(statisticTest.maximum(), 4.5);
-}
-
-BOOST_AUTO_TEST_CASE(fail)
-{
- //BOOST_FAIL("Ende");
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-//____________________________________________________________________________//
-
diff --git a/Utilities/tests/utilitiesTestsGlobalFixture.h b/Utilities/tests/utilitiesTestsGlobalFixture.h
new file mode 100644
--- /dev/null
+++ b/Utilities/tests/utilitiesTestsGlobalFixture.h
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//
+// utilitiesTestGlobalFixture.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2011 The Herwig Collaboration, 2015 Marco A. Harrendorf
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#include <boost/test/unit_test.hpp>
+
+#include "ThePEG/Repository/StandardRandom.h"
+#include "ThePEG/Repository/UseRandom.h"
+
+#include <iostream>
+
+struct FixGlobal1 {
+ FixGlobal1() {
+ BOOST_TEST_MESSAGE( "setup global fixture for utilitiesTest" );
+
+ // Initialize randomNumberGenerator
+ ThePEG::StandardRandom* randomNumberStandardGenerator = new ThePEG::StandardRandom();
+ new ThePEG::UseRandom(randomNumberStandardGenerator);
+ }
+
+ ~FixGlobal1() { BOOST_TEST_MESSAGE( "teardown global fixture for utilitiesTest" ); }
+};
+
+BOOST_GLOBAL_FIXTURE(FixGlobal1)
\ No newline at end of file
diff --git a/Utilities/tests/utilitiesTestsKinematics.h b/Utilities/tests/utilitiesTestsKinematics.h
new file mode 100644
--- /dev/null
+++ b/Utilities/tests/utilitiesTestsKinematics.h
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//
+// utilitiesTestKinematics.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2011 The Herwig Collaboration, 2015 Marco A. Harrendorf
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_Utilities_Test_Kinematics_H
+#define HERWIG_Utilities_Test_Kinematics_H
+
+#include <boost/test/unit_test.hpp>
+
+#include "Herwig++/Utilities/Kinematics.h"
+
+struct FixKinematics1 {
+ FixKinematics1()
+ {BOOST_TEST_MESSAGE( "setup fixture for utilitiesKinematicsTestTest" ); }
+
+ ~FixKinematics1() { BOOST_TEST_MESSAGE( "teardown fixture for utilitiesKinematicsTest" ); }
+};
+
+/*
+ * Start of boost unit tests for Kinematics.h
+ *
+ */
+BOOST_AUTO_TEST_SUITE(utilitiesKinematicsTest)
+
+/*
+ * Boost unit tests
+ *
+ */
+BOOST_AUTO_TEST_CASE(generateAnglestest)
+{
+ double flatMinusPiToPlusPi, flatNullToTwoPi;
+ for(int i = 0; i < 100; ++i) {
+ Herwig::Kinematics::generateAngles(flatMinusPiToPlusPi, flatNullToTwoPi);
+ BOOST_CHECK( -M_PI <= flatMinusPiToPlusPi );
+ BOOST_CHECK( flatMinusPiToPlusPi <= M_PI);
+ BOOST_CHECK( 0. <= flatNullToTwoPi);
+ BOOST_CHECK(flatNullToTwoPi <= 2*M_PI);
+ }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+#endif /* HERWIG_Utilities_Test_Kinematics_H */
\ No newline at end of file
diff --git a/Utilities/tests/utilitiesTestsMain.cc b/Utilities/tests/utilitiesTestsMain.cc
new file mode 100644
--- /dev/null
+++ b/Utilities/tests/utilitiesTestsMain.cc
@@ -0,0 +1,39 @@
+// -*- C++ -*-
+//
+// utilitiesTestMain.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2011 The Herwig Collaboration, 2015 Marco A. Harrendorf
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+
+/**
+ * The following part should be included only once.
+*/
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+#define BOOST_TEST_MODULE utilitiesTest
+
+/**
+ * Include global fixture
+ *
+ * Global fixture initializes the randomNumber generator
+ */
+#include "Herwig++/Utilities/tests/utilitiesTestsGlobalFixture.h"
+
+/**
+ * Include here the sub tests
+ */
+#include "Herwig++/Utilities/tests/utilitiesTestsKinematics.h"
+#include "Herwig++/Utilities/tests/utilitiesTestMaths.h"
+#include "Herwig++/Utilities/tests/utilitiesTestsStatistic.h"
+
+
+/**
+ * Debug and development part
+ */
+BOOST_AUTO_TEST_CASE(fail)
+{
+ //BOOST_FAIL("Ende");
+}
\ No newline at end of file
diff --git a/Utilities/tests/utilitiesTestsStatistic.h b/Utilities/tests/utilitiesTestsStatistic.h
new file mode 100644
--- /dev/null
+++ b/Utilities/tests/utilitiesTestsStatistic.h
@@ -0,0 +1,89 @@
+// -*- C++ -*-
+//
+// utilitiesTestStatistic.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2011 The Herwig Collaboration, 2015 Marco A. Harrendorf
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_Utilities_Test_Statistic_H
+#define HERWIG_Utilities_Test_Statistic_H
+
+#include <boost/test/unit_test.hpp>
+
+#include "Herwig++/Utilities/Statistic.h"
+
+/*
+ * Fixture which defines the common variables for testing Statistic class
+ */
+struct FixStatistic1 {
+ FixStatistic1() : statisticDefault(), statisticTest()
+ {BOOST_TEST_MESSAGE( "setup fixture for utilitiesStatisticTest" ); }
+
+ ~FixStatistic1() { BOOST_TEST_MESSAGE( "teardown fixture for utilitiesStatisticTest" ); }
+
+ Herwig::Statistic statisticDefault;
+ Herwig::Statistic statisticTest;
+};
+
+/*
+ * Start of boost unit tests for Statistic.h
+ *
+ */
+BOOST_FIXTURE_TEST_SUITE(utilitiesStatisticTest, FixStatistic1 )
+
+/*
+ * Boost unit tests
+ *
+ */
+BOOST_AUTO_TEST_CASE(defaultConstructor)
+{
+ BOOST_CHECK_EQUAL(statisticDefault.numberOfPoints(), static_cast<unsigned int>(0));
+ BOOST_CHECK_EQUAL(statisticDefault.total(), 0.);
+ BOOST_CHECK_EQUAL(statisticDefault.mean(), 0.);
+ BOOST_CHECK_EQUAL(statisticDefault.minimum(), -1e100);
+ BOOST_CHECK_EQUAL(statisticDefault.maximum(), 1e100);
+ BOOST_CHECK_EQUAL(statisticDefault.var(), 0);
+ BOOST_CHECK_EQUAL(statisticDefault.mean_var(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(operations)
+{
+ statisticTest += 2;
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), 2);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
+
+ statisticTest += -2;
+ BOOST_CHECK_EQUAL(statisticTest.numberOfPoints(), static_cast<unsigned int>(2));
+ BOOST_CHECK_EQUAL(statisticTest.total(), 0.);
+ BOOST_CHECK_EQUAL(statisticTest.mean(), 0.);
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
+ BOOST_CHECK_EQUAL(statisticTest.var(), 8);
+ BOOST_CHECK_EQUAL(statisticTest.stdDev(), sqrt(8));
+ BOOST_CHECK_EQUAL(statisticTest.mean_var(), 4);
+ BOOST_CHECK_EQUAL(statisticTest.mean_stdDev(), 2);
+
+ statisticTest += 2;
+ BOOST_CHECK_EQUAL(statisticTest.numberOfPoints(), static_cast<unsigned int>(3));
+ BOOST_CHECK_EQUAL(statisticTest.total(), 2.);
+ BOOST_CHECK_EQUAL(statisticTest.mean(), 2./3.);
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
+ BOOST_CHECK_EQUAL(statisticTest.var(), 16./3.);
+ BOOST_CHECK_EQUAL(statisticTest.stdDev(), sqrt(16./3.));
+ BOOST_CHECK_EQUAL(statisticTest.mean_var(), 16./9.);
+ BOOST_CHECK_EQUAL(statisticTest.mean_stdDev(), sqrt(16./9.));
+
+ statisticTest += 4.5;
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 4.5);
+
+ statisticTest += -3.5;
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), -3.5);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 4.5);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+#endif /* HERWIG_Utilities_Test_Statistic_H */
\ No newline at end of file
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Nov 19, 2:57 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3802213
Default Alt Text
(19 KB)
Attached To
R563 testingHerwigHG
Event Timeline
Log In to Comment