diff --git a/tree/tree/test/BulkApiSillyStruct.cxx b/tree/tree/test/BulkApiSillyStruct.cxx index f39dc081e6a92..012cbdaf4079b 100644 --- a/tree/tree/test/BulkApiSillyStruct.cxx +++ b/tree/tree/test/BulkApiSillyStruct.cxx @@ -61,9 +61,9 @@ constexpr Long64_t BulkApiSillyStructTest::fEventCount; TEST_F(BulkApiSillyStructTest, stdReadStruct) { - auto hfile = TFile::Open(fFileName.c_str()); + std::unique_ptr hfile{TFile::Open(fFileName.c_str())}; - TTreeReader myReader("T", hfile); + TTreeReader myReader("T", hfile.get()); TTreeReaderValue ss(myReader, "myEvent"); int evI = 0; @@ -77,14 +77,13 @@ TEST_F(BulkApiSillyStructTest, stdReadStruct) evF++; evD++; } - delete hfile; } TEST_F(BulkApiSillyStructTest, stdReadSplitBranch) { - auto hfile = TFile::Open(fFileName.c_str()); + std::unique_ptr hfile{TFile::Open(fFileName.c_str())}; - TTreeReader myReader("T", hfile); + TTreeReader myReader("T", hfile.get()); TTreeReaderValue myF(myReader, "f"); TTreeReaderValue myI(myReader, "i"); TTreeReaderValue myD(myReader, "d"); @@ -100,7 +99,6 @@ TEST_F(BulkApiSillyStructTest, stdReadSplitBranch) evF++; evD++; } - delete hfile; } TEST_F(BulkApiSillyStructTest, fastRead) @@ -108,7 +106,7 @@ TEST_F(BulkApiSillyStructTest, fastRead) TBufferFile bufF(TBuffer::kWrite, 10000); TBufferFile bufI(TBuffer::kWrite, 10000); TBufferFile bufD(TBuffer::kWrite, 10000); - auto hfile = TFile::Open(fFileName.c_str()); + std::unique_ptr hfile{TFile::Open(fFileName.c_str())}; auto tree = dynamic_cast(hfile->Get("T")); ASSERT_TRUE(tree); TBranch *branchF = tree->GetBranch("f");