Skip to content
Snippets Groups Projects
Commit 0a96514c authored by Axel Naumann's avatar Axel Naumann
Browse files

Extend hist/v7 unittests.

parent 8c938cb9
No related branches found
No related tags found
No related merge requests found
......@@ -3,12 +3,12 @@
#include "TH1.h"
#include "ROOT/THist.h"
// Tests the number of bins
TEST(AxisTest, NumBins) {
// Test "x + 0 = x"
TEST(HistAddTest, AddEmptyHist) {
EXPECT_EQ(0, 0);
}
// Tests the axis range
TEST(AxisTest, RangeFromTo) {
// Test addition of a hist range
TEST(HistAddTest, AddView) {
EXPECT_EQ(1, 1);
}
#include "gtest/gtest.h"
#include <ROOT/TAxis.h>
using namespace ROOT::Experimental;
// Tests the number of bins
TEST(AxisTest, NumBins) {
constexpr int nOverflow = 2;
// Through TAxisConfig
{
TAxisConfig axis(10, 0., 1.);
EXPECT_EQ(10 + nOverflow, axis.GetNBins());
}
{
TAxisConfig axis("TITLE", TAxisConfig::Grow, 10, 0., 1.);
EXPECT_EQ(10 + nOverflow, axis.GetNBins());
}
{
TAxisConfig axis({-0.1, 0.2, 0.5, 10.});
EXPECT_EQ(3 + nOverflow, axis.GetNBins());
}
// Through concrete axis incarnations (and to TAxisConfig)
{
TAxisEquidistant ax("TITLE", 10, -1., 1.);
EXPECT_EQ(10 + nOverflow, ax.GetNBins());
TAxisConfig axcfg(ax);
EXPECT_EQ(ax.GetNBins(), axcfg.GetNBins());
}
{
TAxisGrow ax(10, -1., 1.);
EXPECT_EQ(10 + nOverflow, ax.GetNBins());
TAxisConfig axcfg(ax);
EXPECT_EQ(ax.GetNBins(), axcfg.GetNBins());
}
{
TAxisIrregular ax("TITLE", {-0.1, 0.2, 0.5, 10.});
EXPECT_EQ(3 + nOverflow, ax.GetNBins());
TAxisConfig axcfg(ax);
EXPECT_EQ(ax.GetNBins(), axcfg.GetNBins());
}
}
TEST(AxisTest, ReverseBinLimits) {
{
TAxisConfig axiscfg(10, 1., 0.);
auto axisEq = Internal::AxisConfigToType<TAxisConfig::kEquidistant>()(axiscfg);
EXPECT_DOUBLE_EQ(0., axisEq.GetMinimum());
EXPECT_DOUBLE_EQ(1., axisEq.GetMaximum());
}
}
#include "gtest/gtest.h"
#include <ROOT/THist.h>
#include <ROOT/THistBinIter.h>
using namespace ROOT::Experimental;
// Tests the number of bins
TEST(BinIterNBins, NumBins) {
TH2F h({10, -1., 1.}, {10, -1., 1.});
int nBins = 0;
for (auto &&bin: h) {
(void)bin;
++nBins;
}
EXPECT_EQ(h.GetImpl()->GetNBins(), nBins);
}
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