File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -253,3 +253,30 @@ TEST(RNTupleEvolution, ArrayAsRVec)
253253 EXPECT_EQ (1 , a (0 )[0 ]);
254254 EXPECT_EQ (2 , a (0 )[1 ]);
255255}
256+
257+ TEST (RNTupleEvolution, ArrayAsVector)
258+ {
259+ FileRaii fileGuard (" test_ntuple_evolution_array_as_vector.root" );
260+ {
261+ auto model = ROOT::RNTupleModel::Create ();
262+ auto a = model->MakeField <std::array<int , 2 >>(" a" );
263+ auto writer = ROOT::RNTupleWriter::Recreate (std::move (model), " ntpl" , fileGuard.GetPath ());
264+
265+ *a = {0 , 1 };
266+ writer->Fill ();
267+ }
268+
269+ auto reader = RNTupleReader::Open (" ntpl" , fileGuard.GetPath ());
270+
271+ auto aAsShort = reader->GetView <std::vector<short >>(" a" );
272+ const auto &f = aAsShort.GetField (); // necessary to silence clang warning
273+ EXPECT_EQ (typeid (f), typeid (ROOT::RArrayAsVectorField));
274+ EXPECT_EQ (2u , aAsShort (0 ).size ());
275+ EXPECT_EQ (0 , aAsShort (0 )[0 ]);
276+ EXPECT_EQ (1 , aAsShort (0 )[1 ]);
277+
278+ auto aAsBool = reader->GetView <std::vector<bool >>(" a" );
279+ EXPECT_EQ (2u , aAsBool (0 ).size ());
280+ EXPECT_FALSE (aAsBool (0 )[0 ]);
281+ EXPECT_TRUE (aAsBool (0 )[1 ]);
282+ }
You can’t perform that action at this time.
0 commit comments