mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-07 18:43:26 -08:00
Translate the filter string error at display time (#5283)
Keep the parser message untranslated so FilterStringLog stays in the source language, and format the user-facing text in error() instead. That gives both consumers what they need without localizing the log. Q_DECLARE_TR_FUNCTIONS provides the tr() context without deriving from QObject, which would have deleted copy/move assignment and broken the by-value uses in PlayerActions and ViewZone. Drop the unreachable line-number branch; peglib reports 1-based lines, so every message keeps master's "position" wording. Co-authored-by: Lukas Brübach <44814898+BruebachL@users.noreply.github.com>
This commit is contained in:
parent
7487a383a3
commit
4b224f7fe5
3 changed files with 34 additions and 6 deletions
|
|
@ -279,6 +279,22 @@ TEST_F(SetQuery, ComparisonMatchesByReleaseDate)
|
|||
EXPECT_FALSE(FilterString("set<EOE").check(inBothSets));
|
||||
}
|
||||
|
||||
TEST(FilterStringError, InvalidExpressionIsInvalidAndReportsAPosition)
|
||||
{
|
||||
const FilterString filter("t:(");
|
||||
|
||||
EXPECT_FALSE(filter.valid());
|
||||
EXPECT_TRUE(filter.error().contains("position")) << "unexpected error text: " << filter.error().toStdString();
|
||||
}
|
||||
|
||||
TEST(FilterStringError, ValidExpressionHasNoError)
|
||||
{
|
||||
const FilterString filter("t:creature");
|
||||
|
||||
EXPECT_TRUE(filter.valid());
|
||||
EXPECT_TRUE(filter.error().isEmpty());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue