Skip to content

[io] test for renaming with unversioned classes #18666

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions roottest/root/io/evolution/versions/execROOT14491.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// See https://github.com/root-project/root/issues/14491#issuecomment-1917587621
#ifndef SIMPLEREAD
#define SIMPLEREAD

#include <vector>
#include <iostream>
#include "Rtypes.h"

template <typename T>
struct Wrapper
{
bool present = true;
T obj;
};

struct MatchedCSCSegment
{
float someValue = 0.0;

MatchedCSCSegment(float in = 0.0) : someValue{in} {}

// The simple update failed if the class version was not set.
// ClassDef(MatchedCSCSegment, 5);
};

struct CSCSegment
{
float someValue;

operator MatchedCSCSegment()
{
return MatchedCSCSegment{someValue};
}

std::vector<MatchedCSCSegment> theDuplicateSegments;

// ClassDef(CSCSegment, 4);
};

#ifdef __ROOTCLING__
#pragma link C++ class MatchedCSCSegment+;
#pragma link C++ class CSCSegment+;
#pragma link C++ class Wrapper<std::vector<CSCSegment>>+;
#pragma read sourceClass="CSCSegment" targetClass="MatchedCSCSegment"
#endif

#endif

#include "TFile.h"
#include "TTree.h"

void test(TTree *t, const char *bname)
{
std::string formula = bname;
formula += ".obj.theDuplicateSegments@.size()";
t->Scan(formula.c_str());
}

int execROOT14491()
{
auto file = TFile::Open("oldfile14491.root", "READ");
auto t = file->Get<TTree>("t");
t->LoadTree(0);
// gDebug = 7;
test(t, "seg_split");
// gDebug = 0;
test(t, "seg_unsplit");
file->Close();
delete file;
return 0;
}
13 changes: 13 additions & 0 deletions roottest/root/io/evolution/versions/execROOT14491.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Processing execROOT14491.cxx+...
***********************************
* Row * Instance * seg_split *
***********************************
* 0 * 0 * 0 *
***********************************
***********************************
* Row * Instance * seg_unspl *
***********************************
* 0 * 0 * 1 *
***********************************
(int) 0
Binary file not shown.
Loading