Skip to content

Commit 5a284f3

Browse files
committed
[ntuple] add test for reassigning pending attr range
1 parent 1ff388d commit 5a284f3

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tree/ntuple/test/ntuple_attributes.cxx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,23 @@ TEST(RNTupleAttributes, InvalidPendingRange)
317317
EXPECT_THAT(ex.what(), testing::HasSubstr("was not created by it or was already committed"));
318318
}
319319
}
320+
321+
TEST(RNTupleAttributes, ReassignPendingRange)
322+
{
323+
// verify that reassigning a pending range and not committing it properly triggers the warning.
324+
FileRaii fileGuard("test_ntuple_attr_reassign_range.root");
325+
326+
ROOT::TestSupport::CheckDiagsRAII diagsRaii;
327+
diagsRaii.requiredDiag(kWarning, "ROOT.NTuple", "RNTuple Attributes are experimental", false);
328+
329+
auto file = std::unique_ptr<TFile>(TFile::Open(fileGuard.GetPath().c_str(), "RECREATE"));
330+
auto writer = RNTupleWriter::Append(RNTupleModel::Create(), "ntpl", *file);
331+
auto attrSet = writer->CreateAttributeSet(RNTupleModel::Create(), "MyAttributes");
332+
333+
auto attrRange = attrSet->BeginRange();
334+
attrSet->CommitRange(std::move(attrRange));
335+
// reassign the range but never commit it.
336+
attrRange = attrSet->BeginRange();
337+
338+
diagsRaii.requiredDiag(kWarning, "ROOT.NTuple", "A pending attribute range was not committed", false);
339+
}

0 commit comments

Comments
 (0)