From e9e439e9cb94b4735d9e06436e85cddd944ec9dd Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 14 Nov 2023 16:37:36 +0200 Subject: [PATCH] Fix testing formula translation. --- src/test/ValentinaTest/tst_vtranslatevars.cpp | 15 ++++++++++++--- src/test/ValentinaTest/tst_vtranslatevars.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/test/ValentinaTest/tst_vtranslatevars.cpp b/src/test/ValentinaTest/tst_vtranslatevars.cpp index 36997b8e3..443612684 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.cpp +++ b/src/test/ValentinaTest/tst_vtranslatevars.cpp @@ -42,6 +42,15 @@ TST_VTranslateVars::TST_VTranslateVars(QObject *parent) m_trMs(nullptr), m_systemLocale(QLocale::system()) { + VCommonSettings *settings = VAbstractApplication::VApp()->Settings(); + m_translateFomula = settings->IsTranslateFormula(); + settings->SetTranslateFormula(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +TST_VTranslateVars::~TST_VTranslateVars() +{ + VAbstractApplication::VApp()->Settings()->SetTranslateFormula(m_translateFomula); } //--------------------------------------------------------------------------------------------------------------------- @@ -158,7 +167,7 @@ void TST_VTranslateVars::PrepareVal(const QString &inputFormula, const QString & auto PREPARE_CASE = [locale](const QString &inputString, const QString &outputString) { - QString tag = u"%1. String '%2'"_s.arg(locale.name(), inputString); + QString tag = QStringLiteral("%1. String '%2'").arg(locale.name(), inputString); QTest::newRow(qUtf8Printable(tag)) << inputString << outputString << locale; }; @@ -168,7 +177,7 @@ void TST_VTranslateVars::PrepareVal(const QString &inputFormula, const QString & outputString = outputFormula + '+'_L1 + outputFormula; PREPARE_CASE(inputString, outputString); - inputString = inputFormula + u"+a"_s; - outputString = outputFormula + u"+a"_s; + inputString = inputFormula + "+a"_L1; + outputString = outputFormula + "+a"_L1; PREPARE_CASE(inputString, outputString); } diff --git a/src/test/ValentinaTest/tst_vtranslatevars.h b/src/test/ValentinaTest/tst_vtranslatevars.h index ac2952745..25cc506ba 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.h +++ b/src/test/ValentinaTest/tst_vtranslatevars.h @@ -45,6 +45,7 @@ class TST_VTranslateVars : public QObject public: explicit TST_VTranslateVars(QObject *parent = nullptr); + ~TST_VTranslateVars() override; private slots: void initTestCase(); void TestFormulaFromUser_data(); @@ -58,6 +59,7 @@ private: Q_DISABLE_COPY_MOVE(TST_VTranslateVars) // NOLINT VTranslateVars *m_trMs; QLocale m_systemLocale; + bool m_translateFomula{true}; void PrepareValFromUser(double d, const QLocale &locale); void PrepareValToUser(double d, const QLocale &locale);