 |
Belle II Software
release-05-01-25
|
1 #include <framework/logging/Logger.h>
3 #include <framework/utilities/TestHelpers.h>
5 #include <framework/gearbox/Gearbox.h>
10 #include <boost/filesystem.hpp>
11 #include <boost/math/special_functions/sign.hpp>
16 using namespace boost::filesystem;
23 std::vector<std::string> backends;
24 backends.emplace_back(
"file:");
25 gearbox.setBackends(backends);
27 B2INFO(
"Start open gearbox.");
28 gearbox.open(
"geometry/Belle2.xml");
29 B2INFO(
"Finished open gearbox.");
39 m_oldpwd(current_path().string())
41 path tmpdir = temp_directory_path() / unique_path();
42 create_directories(tmpdir);
60 return fabs(remainder(expected - actual, 2 * M_PI)) < absError;
65 if (std::isnan(expected) or std::isnan(actual))
return false;
66 using boost::math::sign;
67 int expectedSign = sign(expected);
68 int actualSign = sign(actual);
69 return expectedSign == actualSign;
84 const TVector3& actual,
87 bool xNear = std::fabs(expected.X() - actual.X()) < tolerance;
88 bool yNear = std::fabs(expected.Y() - actual.Y()) < tolerance;
89 bool zNear = std::fabs(expected.Z() - actual.Z()) < tolerance;
90 return xNear and yNear and zNear;
97 << tVector3.X() <<
", "
98 << tVector3.Y() <<
", "
99 << tVector3.Z() <<
")";
bool isNegative(double expected)
Predicate checking that a value is smaller than zero.
static Gearbox & getInstance()
Return reference to the Gearbox instance.
bool allNear< TVector3 >(const TVector3 &expected, const TVector3 &actual, double tolerance)
Predicate checking that all three components of TVector3 are close by a maximal error of tolerance.
static void TearDownTestCase()
Closes the Gearbox once for all test in this TestCase.
bool angleNear(double expected, double actual, double tolerance)
Predicate checking that two angular values are close to each other modulus a 2 * PI difference.
std::string m_tmpdir
path of temporary director.
Some utilities to help with writing unit tests.
Singleton class responsible for loading detector parameters from an XML file.
std::string m_oldpwd
previous working directory.
static void SetUpTestCase()
Sets up the Gearbox once for all test in this TestCase.
bool isPositive(double expected)
Predicate checking that a value is bigger than zero.
bool sameSign(double expected, double actual)
Predicate checking that two values have the same sign.
std::string getTempDir() const
Returns path of temporary directory.
void PrintTo(const TVector3 &tVector3, ::std::ostream &output)
Print function for the google test framework to print a TVector3 to an output stream.