8 #include <framework/logging/Logger.h>
10 #include <framework/utilities/TestHelpers.h>
12 #include <framework/gearbox/Gearbox.h>
17 #include <boost/filesystem.hpp>
18 #include <boost/math/special_functions/sign.hpp>
23 using namespace boost::filesystem;
30 std::vector<std::string> backends;
31 backends.emplace_back(
"file:");
32 gearbox.setBackends(backends);
34 B2INFO(
"Start open gearbox.");
35 gearbox.open(
"geometry/Belle2.xml");
36 B2INFO(
"Finished open gearbox.");
46 m_oldpwd(current_path().string())
48 path tmpdir = temp_directory_path() / unique_path();
49 create_directories(tmpdir);
67 return fabs(remainder(expected - actual, 2 * M_PI)) < absError;
72 if (std::isnan(expected) or std::isnan(actual))
return false;
73 using boost::math::sign;
74 int expectedSign = sign(expected);
75 int actualSign = sign(actual);
76 return expectedSign == actualSign;
91 const TVector3& actual,
94 bool xNear = std::fabs(expected.X() - actual.X()) < tolerance;
95 bool yNear = std::fabs(expected.Y() - actual.Y()) < tolerance;
96 bool zNear = std::fabs(expected.Z() - actual.Z()) < tolerance;
97 return xNear and yNear and zNear;
104 << tVector3.X() <<
", "
105 << tVector3.Y() <<
", "
106 << tVector3.Z() <<
")";
Singleton class responsible for loading detector parameters from an XML file.
std::string getTempDir() const
Returns path of temporary directory.
std::string m_tmpdir
path of temporary director.
std::string m_oldpwd
previous working directory.
static void SetUpTestCase()
Sets up the Gearbox once for all test in this TestCase.
static void TearDownTestCase()
Closes the Gearbox once for all test in this TestCase.
static Gearbox & getInstance()
Return reference to the Gearbox instance.
Some utilities to help with writing unit tests.
void PrintTo(const TVector3 &tVector3, ::std::ostream &output)
Print function for the google test framework to print a TVector3 to an output stream.
bool isPositive(double expected)
Predicate checking that a value is bigger than zero.
bool angleNear(double expected, double actual, double tolerance)
Predicate checking that two angular values are close to each other modulus a 2 * PI difference.
bool isNegative(double expected)
Predicate checking that a value is smaller than zero.
bool sameSign(double expected, double actual)
Predicate checking that two values have the same sign.
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.