@@ -547,27 +547,43 @@ TEST(RNTuple, ModelId)
547
547
548
548
TEST (RNTuple, Entry)
549
549
{
550
- auto m1 = RNTupleModel::Create ();
550
+ auto m = RNTupleModel::Create ();
551
551
try {
552
- m1 ->CreateEntry ();
552
+ m ->CreateEntry ();
553
553
FAIL () << " creating entry of unfrozen model should throw" ;
554
554
} catch (const ROOT::RException &err) {
555
555
EXPECT_THAT (err.what (), testing::HasSubstr (" invalid attempt to create entry" ));
556
556
}
557
- m1 ->Freeze ();
558
- auto e1 = m1 ->CreateEntry ();
557
+ m ->Freeze ();
558
+ auto e = m ->CreateEntry ();
559
559
560
- auto m2 = RNTupleModel::Create ();
561
- m2 ->Freeze ();
562
- auto e2 = m2 ->CreateEntry ();
560
+ auto mWrite = m-> Clone ();
561
+ mWrite ->Freeze ();
562
+ auto eWrite = mWrite ->CreateEntry ();
563
563
564
564
FileRaii fileGuard (" test_ntuple_entry.root" );
565
- auto ntuple = RNTupleWriter::Recreate (std::move (m1), " ntpl" , fileGuard.GetPath ());
566
- ntuple->Fill ();
567
- ntuple->Fill (*e1 );
565
+ {
566
+ auto ntuple = RNTupleWriter::Recreate (std::move (mWrite ), " ntpl" , fileGuard.GetPath ());
567
+ ntuple->Fill ();
568
+ ntuple->Fill (*eWrite);
569
+ try {
570
+ ntuple->Fill (*e);
571
+ FAIL () << " filling with wrong entry should throw" ;
572
+ } catch (const ROOT::RException &err) {
573
+ EXPECT_THAT (err.what (), testing::HasSubstr (" mismatch between entry and model" ));
574
+ }
575
+ }
576
+
577
+ auto mRead = m->Clone ();
578
+ mRead ->Freeze ();
579
+ auto eRead = mRead ->CreateEntry ();
580
+
581
+ auto ntuple = RNTupleReader::Open (std::move (mRead ), " ntpl" , fileGuard.GetPath ());
582
+ ntuple->LoadEntry (0 );
583
+ ntuple->LoadEntry (0 , *eRead);
568
584
try {
569
- ntuple->Fill (* e2 );
570
- FAIL () << " filling with wrong entry should throw" ;
585
+ ntuple->LoadEntry ( 0 , *e );
586
+ FAIL () << " loading the wrong entry should throw" ;
571
587
} catch (const ROOT::RException &err) {
572
588
EXPECT_THAT (err.what (), testing::HasSubstr (" mismatch between entry and model" ));
573
589
}
0 commit comments