Skip to content

Commit 75e9f56

Browse files
[test] TFormula unbalanced: check error detection and IsValid value
[test] singleQuote printed string Co-authored-by: Vincenzo Eduardo Padulano <v.e.padulano@gmail.com>
1 parent 4e2dc81 commit 75e9f56

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

hist/hist/src/TFormula.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool isBalanced(const TString &s)
6464
i.push(s[c]);
6565
} else if (s[c] == ']' || s[c] == '}' || s[c] == ')') {
6666
if (i.empty() || !areMatching(i.top(), s[c])) {
67-
Error("TFormula", "Found unbalanced char %c (expected closing of %c) at index %d of %s", s[c], i.top(), c,
67+
Error("TFormula", "Found unbalanced char '%c' (expected closing of '%c') at index %d of '%s'", s[c], i.top(), c,
6868
s.Data());
6969
return false;
7070
} else
@@ -80,7 +80,7 @@ bool isBalanced(const TString &s)
8080
}
8181
}
8282
if (!i.empty()) {
83-
Error("TFormula", "String %s with %zu unbalanced chars.", s.Data(), i.size());
83+
Error("TFormula", "String '%s' with %zu unbalanced chars.", s.Data(), i.size());
8484
return false;
8585
}
8686
return true;

hist/hist/test/test_TFormula.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,13 @@ TEST(TFormulaPolTest, CompoundExpressions)
102102
// https://github.com/root-project/root/issues/21104
103103
TEST(TFormula, SingleOpeningBracket)
104104
{
105+
ROOT::TestSupport::CheckDiagsRAII diags;
106+
diags.requiredDiag(kError, "TFormula", "String '[' with 1 unbalanced chars.");
105107
TFormula f1("f1", "[");
108+
EXPECT_FALSE(f1.IsValid());
106109
EXPECT_EQ(f1.GetNdim(), 0);
110+
diags.requiredDiag(kError, "TFormula", "String '(' with 1 unbalanced chars.");
107111
TFormula f2("f2", "(");
112+
EXPECT_FALSE(f2.IsValid());
108113
EXPECT_EQ(f2.GetNdim(), 0);
109114
}

0 commit comments

Comments
 (0)