diff --git a/hist/hist/v7/unit/add.cxx b/hist/hist/v7/unit/add.cxx index fbc39592337101e5251c375181bcd4d4910da3a1..5aaad0517b0fc0852196bcbd8167897e0bae88ab 100644 --- a/hist/hist/v7/unit/add.cxx +++ b/hist/hist/v7/unit/add.cxx @@ -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); } diff --git a/hist/hist/v7/unit/axis.cxx b/hist/hist/v7/unit/axis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..45d2df45d757cdd6a73aeb4825505995cccf4728 --- /dev/null +++ b/hist/hist/v7/unit/axis.cxx @@ -0,0 +1,55 @@ +#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()); + } +} diff --git a/hist/hist/v7/unit/biniter.cxx b/hist/hist/v7/unit/biniter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..af32a9abe35d5b42f6eb5ffb6c4aaef2620e00a7 --- /dev/null +++ b/hist/hist/v7/unit/biniter.cxx @@ -0,0 +1,17 @@ +#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); +} +