Skip to content
Snippets Groups Projects
Commit db183448 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Make Catch2 based test compatible with Catch2 v3

Closes #252

See merge request !1407
parents 120d966c d77132d6
No related branches found
No related tags found
1 merge request!1407Make Catch2 based test compatible with Catch2 v3
Pipeline #5034589 passed
......@@ -9,7 +9,18 @@
* or submit itself to any jurisdiction. *
\***********************************************************************************/
#include <Gaudi/Accumulators.h>
#include <catch2/catch.hpp>
#if __has_include( <catch2/catch.hpp>)
// Catch2 v2
# include <catch2/catch.hpp>
namespace Catch {
using Detail::Approx;
}
#else
// Catch2 v3
# include <catch2/catch_approx.hpp>
# include <catch2/catch_template_test_macros.hpp>
# include <catch2/catch_test_macros.hpp>
#endif
using namespace Gaudi::Accumulators;
......@@ -109,7 +120,7 @@ namespace {
CHECK( j["sum"].get<double>() == 60 );
CHECK( j["mean"].get<double>() == 20 );
CHECK( j["sum2"].get<double>() == 1400 );
CHECK( j["standard_deviation"].get<double>() == Approx( 8.164966 ) );
CHECK( j["standard_deviation"].get<double>() == Catch::Approx( 8.164966 ) );
}
}
};
......@@ -134,7 +145,7 @@ namespace {
CHECK( j["sum"].get<double>() == 60 );
CHECK( j["mean"].get<double>() == 20 );
CHECK( j["sum2"].get<double>() == 1400 );
CHECK( j["standard_deviation"].get<double>() == Approx( 8.164966 ) );
CHECK( j["standard_deviation"].get<double>() == Catch::Approx( 8.164966 ) );
CHECK( j["min"].get<double>() == 10 );
CHECK( j["max"].get<double>() == 30 );
}
......@@ -160,7 +171,7 @@ namespace {
CHECK( j["nTrueEntries"].get<double>() == 5 );
CHECK( j["nFalseEntries"].get<double>() == 5 );
CHECK( j["efficiency"].get<double>() == 0.5 );
CHECK( j["efficiencyErr"].get<double>() == Approx( 0.158114 ) );
CHECK( j["efficiencyErr"].get<double>() == Catch::Approx( 0.158114 ) );
}
}
};
......
......@@ -9,12 +9,19 @@
* or submit itself to any jurisdiction. *
\***********************************************************************************/
#include <Gaudi/Accumulators.h>
#include <catch2/catch.hpp>
#include <map>
#include <optional>
#include <string>
#include <utility>
#if __has_include( <catch2/catch.hpp>)
// Catch2 v2
# include <catch2/catch.hpp>
#else
// Catch2 v3
# include <catch2/catch_test_macros.hpp>
#endif
namespace {
/// Mock helpers to be able to invoke counters auto registering constructor.
Gaudi::Monitoring::Hub localHub;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment