[core] Add new ROOT/StringUtils.hxx file with ROOT::Split function#8821
[core] Add new ROOT/StringUtils.hxx file with ROOT::Split function#8821guitargeek merged 3 commits intoroot-project:masterfrom
Conversation
cc46cd1 to
b1438e0
Compare
|
Starting build on |
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
hageboeck
left a comment
There was a problem hiding this comment.
LGTM, but I have 2 more suggestions.
| auto test = [](std::string_view in, std::vector<std::string> const &ref) { | ||
| auto out = ROOT::Split(in, ","); | ||
| EXPECT_EQ(out, ref) << "ROOT::Split(\"" << in << "\") gave wrong result."; | ||
| }; | ||
|
|
||
| test("a,b,c", {"a", "b", "c"}); | ||
| test("a,,c", {"a", "", "c"}); | ||
| test("a,,,", {"a", "", "", ""}); | ||
| test(",,a,,,", {"", "", "a", "", "", ""}); | ||
| test(",,,", {"", "", "", ""}); | ||
| test(",,a", {"", "", "a"}); | ||
| test("", {""}); |
There was a problem hiding this comment.
| auto test = [](std::string_view in, std::vector<std::string> const &ref) { | |
| auto out = ROOT::Split(in, ","); | |
| EXPECT_EQ(out, ref) << "ROOT::Split(\"" << in << "\") gave wrong result."; | |
| }; | |
| test("a,b,c", {"a", "b", "c"}); | |
| test("a,,c", {"a", "", "c"}); | |
| test("a,,,", {"a", "", "", ""}); | |
| test(",,a,,,", {"", "", "a", "", "", ""}); | |
| test(",,,", {"", "", "", ""}); | |
| test(",,a", {"", "", "a"}); | |
| test("", {""}); | |
| auto test = [](std::string_view in, std::vector<std::string> const &ref, bool skipEmpty) { | |
| auto out = ROOT::Split(in, ",", skipEmpty); | |
| EXPECT_EQ(out, ref) << "ROOT::Split(\"" << in << "\") gave wrong result."; | |
| }; | |
| test("a,b,c", {"a", "b", "c"}, false); | |
| test("a,b,c", {"a", "b", "c"}, true); | |
| test("a,,c", {"a", "", "c"}, false); | |
| test("a,,c", {"a", "c"}, true); | |
| test("a,,,", {"a", "", "", ""}, false); | |
| test(",,a,,,", {"", "", "a", "", "", ""}, false); | |
| test(",,,", {"", "", "", ""}, false); | |
| test(",,,", {}, true); | |
| test(",,a", {"", "", "a"}, false); | |
| test("", {""}, false); |
There was a problem hiding this comment.
Good idea! I have changed that.
| #include "RooHelpers.h" | ||
| #include "RooBatchCompute.h" | ||
| #include "RooFormulaVar.h" | ||
| #include "RooDerivative.h" |
There was a problem hiding this comment.
That's here intentionally? (One could argue that this better goes into an extra commit, but maybe too much work).
There was a problem hiding this comment.
This is just to reorder the includes such that the RooFit includes appear before the remaining ROOT includes. Since I was touching the incudes, I thought why not do that
There was a problem hiding this comment.
Sure, that's a good idea, but there was no such include before if I'm not mistaken?
Edit: Ah, never mind. 🙂
The `ROOT::Split` function splits a string in the same way as the `str.split` function from Python.
b1438e0 to
e1efcd3
Compare
|
Starting build on |
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
|
Build failed on windows10/cxx14. Failing tests: |
The
ROOT::Splitfunction splits a string in the same way as thestr.splitfunction from Python.Closes #8807.