Fix testing formula translation.

This commit is contained in:
Roman Telezhynskyi 2023-11-14 16:37:36 +02:00
parent 4691de62fd
commit e9e439e9cb
2 changed files with 14 additions and 3 deletions

View File

@ -42,6 +42,15 @@ TST_VTranslateVars::TST_VTranslateVars(QObject *parent)
m_trMs(nullptr), m_trMs(nullptr),
m_systemLocale(QLocale::system()) 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) 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; QTest::newRow(qUtf8Printable(tag)) << inputString << outputString << locale;
}; };
@ -168,7 +177,7 @@ void TST_VTranslateVars::PrepareVal(const QString &inputFormula, const QString &
outputString = outputFormula + '+'_L1 + outputFormula; outputString = outputFormula + '+'_L1 + outputFormula;
PREPARE_CASE(inputString, outputString); PREPARE_CASE(inputString, outputString);
inputString = inputFormula + u"+a"_s; inputString = inputFormula + "+a"_L1;
outputString = outputFormula + u"+a"_s; outputString = outputFormula + "+a"_L1;
PREPARE_CASE(inputString, outputString); PREPARE_CASE(inputString, outputString);
} }

View File

@ -45,6 +45,7 @@ class TST_VTranslateVars : public QObject
public: public:
explicit TST_VTranslateVars(QObject *parent = nullptr); explicit TST_VTranslateVars(QObject *parent = nullptr);
~TST_VTranslateVars() override;
private slots: private slots:
void initTestCase(); void initTestCase();
void TestFormulaFromUser_data(); void TestFormulaFromUser_data();
@ -58,6 +59,7 @@ private:
Q_DISABLE_COPY_MOVE(TST_VTranslateVars) // NOLINT Q_DISABLE_COPY_MOVE(TST_VTranslateVars) // NOLINT
VTranslateVars *m_trMs; VTranslateVars *m_trMs;
QLocale m_systemLocale; QLocale m_systemLocale;
bool m_translateFomula{true};
void PrepareValFromUser(double d, const QLocale &locale); void PrepareValFromUser(double d, const QLocale &locale);
void PrepareValToUser(double d, const QLocale &locale); void PrepareValToUser(double d, const QLocale &locale);