Skip to content

Commit

Permalink
[TChain] Add tests for name parsing in TChain::[Add,AddFile]
Browse files Browse the repository at this point in the history
  • Loading branch information
stwunsch committed Feb 22, 2020
1 parent 86bb093 commit 8795698
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions tree/tree/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ROOT_ADD_GTEST(testTBasket TBasket.cxx LIBRARIES RIO Tree)
ROOT_ADD_GTEST(testTBranch TBranch.cxx LIBRARIES RIO Tree MathCore)
ROOT_ADD_GTEST(testTIOFeatures TIOFeatures.cxx LIBRARIES RIO Tree)
ROOT_ADD_GTEST(testTTreeCluster TTreeClusterTest.cxx LIBRARIES RIO Tree MathCore)
ROOT_ADD_GTEST(testTChainParsing TChainParsing.cxx LIBRARIES RIO Tree)
if(imt)
ROOT_ADD_GTEST(testTTreeImplicitMT ImplicitMT.cxx LIBRARIES RIO Tree)
endif()
Expand Down
66 changes: 66 additions & 0 deletions tree/tree/test/TChainParsing.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "TChain.h"
#include "gtest/gtest.h"

TEST(TChainParsing, RemoteAdd)
{
TChain c;
c.Add("root://some.domain/path/to/file.root/treename");
c.Add("root://some.domain//path/to/file.root/treename");
c.Add("root://some.domain/path/to/foo.something/file.root/treename");
c.Add("root://some.domain/path/to/foo.root/file.root/treename"); // ROOT-9344
c.Add("root://some.domain/path//to/file.root/treename"); // ROOT-10494
const auto files = c.GetListOfFiles();

EXPECT_STREQ(files->At(0)->GetTitle(), "root://some.domain/path/to/file.root");
EXPECT_STREQ(files->At(0)->GetName(), "treename");

EXPECT_STREQ(files->At(1)->GetTitle(), "root://some.domain//path/to/file.root");
EXPECT_STREQ(files->At(1)->GetName(), "treename");

EXPECT_STREQ(files->At(2)->GetTitle(), "root://some.domain/path/to/foo.something/file.root");
EXPECT_STREQ(files->At(2)->GetName(), "treename");

EXPECT_STREQ(files->At(3)->GetTitle(), "root://some.domain/path/to/foo.root/file.root");
EXPECT_STREQ(files->At(3)->GetName(), "treename");

EXPECT_STREQ(files->At(4)->GetTitle(), "root://some.domain/path//to/file.root");
EXPECT_STREQ(files->At(4)->GetName(), "treename");
}

TEST(TChainParsing, LocalAdd)
{
TChain c;
c.Add("/path/to/file.root");
c.Add("/path/to/file.root/foo");
c.Add("/path/to/file.root/foo/bar");
c.Add("/path/to/file.root/foo.bar/treename");
c.Add("/path/to/file.root/foo.root/treename");
c.Add("/path/to/file.root/root/treename");
c.Add("path/to/file.root/treename");
c.Add("/path/to/file.root//treename");
const auto files = c.GetListOfFiles();

EXPECT_STREQ(files->At(0)->GetTitle(), "/path/to/file.root");
EXPECT_STREQ(files->At(0)->GetName(), "");

EXPECT_STREQ(files->At(1)->GetTitle(), "/path/to/file.root");
EXPECT_STREQ(files->At(1)->GetName(), "foo");

EXPECT_STREQ(files->At(2)->GetTitle(), "/path/to/file.root");
EXPECT_STREQ(files->At(2)->GetName(), "foo/bar");

EXPECT_STREQ(files->At(3)->GetTitle(), "/path/to/file.root");
EXPECT_STREQ(files->At(3)->GetName(), "foo.bar/treename");

EXPECT_STREQ(files->At(4)->GetTitle(), "/path/to/file.root/foo.root");
EXPECT_STREQ(files->At(4)->GetName(), "treename");

EXPECT_STREQ(files->At(5)->GetTitle(), "/path/to/file.root");
EXPECT_STREQ(files->At(5)->GetName(), "root/treename");

EXPECT_STREQ(files->At(6)->GetTitle(), "path/to/file.root");
EXPECT_STREQ(files->At(6)->GetName(), "treename");

EXPECT_STREQ(files->At(7)->GetTitle(), "/path/to/file.root");
EXPECT_STREQ(files->At(7)->GetName(), "/treename");
}

0 comments on commit 8795698

Please sign in to comment.