@@ -395,37 +395,40 @@ TEST(RNTuple, TClassMetaName)
395395
396396TEST (RNTuple, StreamerInfoRecords)
397397{
398- // Every testee consists of the type stored on disk and the expected streamer info records
399- std::vector<std::pair<std::string, std::vector<std::string>>> testees{
400- {" float" , {}},
401- {" std::vector<float>" , {}},
402- {" std::pair<float, float>" , {}},
403- {" std::map<int, float>" , {}},
404- {" CustomStruct" , {" CustomStruct" }},
405- {" std::vector<CustomStruct>" , {" CustomStruct" }},
406- {" std::map<int, CustomStruct>" , {" CustomStruct" }},
407- {" DerivedA" , {" DerivedA" , " CustomStruct" }},
408- {" std::pair<CustomStruct, DerivedA>" , {" DerivedA" , " CustomStruct" }},
409- {" EdmWrapper<long long>" , {" EdmWrapper<Long64_t>" }},
410- {" TRotation" , {" TRotation" }}};
398+ // Every testee consists of the type stored on disk, the expected streamer info records, and the expected type alias
399+ std::vector<std::tuple<std::string, std::vector<std::string>, std::string>> testees{
400+ {" float" , {}, " " },
401+ {" std::vector<float>" , {}, " " },
402+ {" std::pair<float, float>" , {}, " " },
403+ {" std::map<int, float>" , {}, " " },
404+ {" CustomStruct" , {" CustomStruct" }, " " },
405+ {" std::vector<CustomStruct>" , {" CustomStruct" }, " " },
406+ {" std::map<int, CustomStruct>" , {" CustomStruct" }, " " },
407+ {" DerivedA" , {" DerivedA" , " CustomStruct" }, " " },
408+ {" std::pair<CustomStruct, DerivedA>" , {" DerivedA" , " CustomStruct" }, " " },
409+ {" EdmWrapper<long long>" , {" EdmWrapper<Long64_t>" }, " EdmWrapper<Long64_t>" },
410+ {" EdmContainer" , {" EdmContainer" , " EdmWrapper<Long64_t>" }, " " },
411+ {" EdmWrapper<long long>::Inner" , {" EdmWrapper<Long64_t>::Inner" }, " EdmWrapper<Long64_t>::Inner" },
412+ {" EdmContainer::EdmWrapperLong64_t" , {" EdmWrapper<Long64_t>" }, " EdmContainer::EdmWrapperLong64_t" },
413+ {" TRotation" , {" TRotation" }, " " }};
411414
412415 for (const auto &t : testees) {
413416 FileRaii fileGuard (" test_ntuple_streamer_info_records.root" );
414417
415418 {
416419 auto model = ROOT::RNTupleModel::Create ();
417- if (t. first == " TRotation" ) {
418- model->AddField (std::make_unique<ROOT::RStreamerField>(" f" , t. first ));
420+ if (std::get< 0 >(t) == " TRotation" ) {
421+ model->AddField (std::make_unique<ROOT::RStreamerField>(" f" , std::get< 0 >(t) ));
419422 } else {
420- model->AddField (ROOT::RFieldBase::Create (" f" , t. first ).Unwrap ());
423+ model->AddField (ROOT::RFieldBase::Create (" f" , std::get< 0 >(t) ).Unwrap ());
421424 }
422425 auto writer = ROOT::RNTupleWriter::Recreate (std::move (model), " ntpl" , fileGuard.GetPath ());
423426 }
424427
425428 auto f = std::unique_ptr<TFile>(TFile::Open (fileGuard.GetPath ().c_str ()));
426429 ASSERT_TRUE (f && !f->IsZombie ());
427430
428- std::unordered_set<std::string> expectedInfos{t. second . begin (), t. second .end ()};
431+ std::unordered_set<std::string> expectedInfos{std::get< 1 >(t). begin (), std::get< 1 >(t) .end ()};
429432 expectedInfos.insert (" ROOT::RNTuple" );
430433 for (const auto info : TRangeDynCast<TVirtualStreamerInfo>(*f->GetStreamerInfoList ())) {
431434 auto itr = expectedInfos.find (info->GetName ());
@@ -436,5 +439,12 @@ TEST(RNTuple, StreamerInfoRecords)
436439 expectedInfos.erase (itr);
437440 }
438441 EXPECT_TRUE (expectedInfos.empty ());
442+
443+ // Make sure we can reconstruct the fields
444+ auto reader = RNTupleReader::Open (" ntpl" , fileGuard.GetPath ());
445+ EXPECT_EQ (std::get<2 >(t), reader->GetModel ().GetConstField (" f" ).GetTypeAlias ());
446+ if (auto field = dynamic_cast <const ROOT::RClassField *>(&reader->GetModel ().GetConstField (" f" ))) {
447+ EXPECT_EQ (std::get<1 >(t)[0 ], field->GetClass ()->GetName ());
448+ }
439449 }
440450}
0 commit comments