15#define BOOST_TEST_MODULE Test MID geometry transformer
16#define BOOST_TEST_DYN_LINK
18#include <boost/test/unit_test.hpp>
23#include <boost/test/data/test_case.hpp>
26#include <rapidjson/filereadstream.h>
27#include <rapidjson/document.h>
30template <
typename StreamType>
36 mReadBuffer(new
char[65536]),
37 mStream(mFile, mReadBuffer, sizeof(mReadBuffer)),
40 mDocument.ParseStream(mStream);
43 rapidjson::Document&
document() {
return mDocument; }
55 rapidjson::Document mDocument;
59namespace bdata = boost::unit_test::data;
61BOOST_AUTO_TEST_SUITE(o2_mid_simulation)
65 return std::fabs(
b -
a) < 1E-4;
70 for (
int idim = 0; idim < 3; ++idim) {
80 auto deId = tp[
"deId"].GetInt();
81 auto localPoint = tp[
"local"].GetArray();
82 auto inGlobalPoint = tp[
"global"].GetArray();
83 std::array<double, 3> inGlob = {inGlobalPoint[0].GetDouble(), inGlobalPoint[1].GetDouble(), inGlobalPoint[2].GetDouble()};
84 auto outGlobalPoint = geoTrans.
localToGlobal(deId, localPoint[0].GetDouble(), localPoint[1].GetDouble());
85 std::array<double, 3> outGlob = {outGlobalPoint.x(), outGlobalPoint.y(), outGlobalPoint.z()};
87 std::cout <<
"got different positions for deId " << deId <<
" : got (" << inGlob[0] <<
", " << inGlob[1] <<
", " << inGlob[2] <<
") expected (" << outGlob[0] <<
", " << outGlob[1] <<
", " << outGlob[2] <<
")\n";
95 std::string
path =
"test_random_pos.json";
96 auto& ts = boost::unit_test::framework::master_test_suite();
99 std::string opt{
"--testpos"};
100 for (
auto iarg = 0; iarg < nargs - 1; iarg++) {
101 if (opt == ts.argv[iarg]) {
102 path = ts.argv[iarg + 1];
121 BOOST_TEST(
false,
"No test file found. Do it with: test_MIDpositions -- --testpos <testFilename>");
126 rapidjson::Value& test_positions =
data.document()[
"testpositions"];
134 for (
auto& tp : test_positions.GetArray()) {
140BOOST_AUTO_TEST_SUITE_END()
constexpr int p1()
constexpr to accelerate the coordinates changing
std::string getTestPosFilename()
bool fileExists(const char *filename)
bool areEqual(double a, double b)
BOOST_AUTO_TEST_CASE(TestPositions)
int testOnePosition(const o2::mid::GeometryTransformer &geoTrans, rapidjson::Value &tp)
GLboolean GLboolean GLboolean b
GLsizei const GLchar *const * path
GLboolean GLboolean GLboolean GLboolean a
GeometryTransformer createDefaultTransformer()
BOOST_TEST(digits==digitsD, boost::test_tools::per_element())