8#include <framework/logging/Logger.h>
10#include <framework/utilities/TestHelpers.h>
12#include <framework/gearbox/Gearbox.h>
17#include <boost/math/special_functions/sign.hpp>
23using namespace std::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 char* temporaryDirName = strdup((temp_directory_path() /
"basf2_XXXXXX").c_str());
49 auto directory = mkdtemp(temporaryDirName);
51 B2ERROR(
"Cannot create temporary directory: " << strerror(errno));
52 free(temporaryDirName);
55 path tmpdir = directory;
58 free(temporaryDirName);
74 return fabs(remainder(expected - actual, 2 * M_PI)) < absError;
79 if (std::isnan(expected) or std::isnan(actual))
return false;
80 using boost::math::sign;
81 int expectedSign = sign(expected);
82 int actualSign = sign(actual);
83 return expectedSign == actualSign;
98 const ROOT::Math::XYZVector& actual,
101 bool xNear = std::fabs(expected.X() - actual.X()) < tolerance;
102 bool yNear = std::fabs(expected.Y() - actual.Y()) < tolerance;
103 bool zNear = std::fabs(expected.Z() - actual.Z()) < tolerance;
104 return xNear and yNear and zNear;
111 << tVector3.X() <<
", "
112 << tVector3.Y() <<
", "
113 << 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 allNear< ROOT::Math::XYZVector >(const ROOT::Math::XYZVector &expected, const ROOT::Math::XYZVector &actual, double tolerance)
Predicate checking that all three components of XYZVector are close by a maximal error of tolerance.
bool sameSign(double expected, double actual)
Predicate checking that two values have the same sign.