Skip to content

Commit 5d75325

Browse files
committed
[roottest] Add a test to read an hbook file.
1 parent 3774e0e commit 5d75325

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

roottest/root/hist/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ if(fortran AND CMAKE_Fortran_COMPILER AND NOT CMAKE_Fortran_COMPILER_ID STREQUAL
1111
COMMAND h2root mb4i1.hbook
1212
COPY_TO_BUILDDIR mb4i1.hbook
1313
OUTREF h2root.ref)
14+
ROOT_ADD_GTEST(THbookFile THbookFile.cxx
15+
LIBRARIES Hbook
16+
COPY_TO_BUILDDIR mb4i1.hbook)
1417
endif()
1518

1619
ROOTTEST_ADD_TESTDIRS()

roottest/root/hist/THbookFile.cxx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <THbookFile.h>
2+
#include <TH1F.h>
3+
4+
#include "gtest/gtest.h"
5+
6+
TEST(THbookFile, ReadTH1)
7+
{
8+
THbookFile file("roottest/root/hist/mb4i1.hbook");
9+
EXPECT_STREQ(file.GetCurDir(), "//lun10");
10+
EXPECT_EQ(file.GetListOfKeys()->size(), 9);
11+
12+
TObject *histo = file.Get(1);
13+
auto th1 = dynamic_cast<TH1F *>(histo);
14+
ASSERT_NE(th1, nullptr);
15+
EXPECT_EQ(th1->GetEntries(), 500);
16+
}

0 commit comments

Comments
 (0)