Simple fix for the omitted multiplication sign before a left parenthesis (#1661)

* simple fix for the omitted multiplication sign

* accepts unary-op-code
This commit is contained in:
Tian L 2021-08-26 10:58:36 +08:00 committed by GitHub
parent 8797e37e73
commit 10ae9430a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -519,6 +519,12 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
if (wParam == IDC_OPENP)
{
// if there's an omitted multiplication sign
if (IsDigitOpCode(m_nLastCom) || IsUnaryOpCode(m_nLastCom) || m_nLastCom == IDC_PNT || m_nLastCom == IDC_CLOSEP)
{
ProcessCommand(IDC_MUL);
}
CheckAndAddLastBinOpToHistory();
m_HistoryCollector.AddOpenBraceToHistory();

View File

@ -633,16 +633,16 @@ namespace CalculatorManagerTest
Command commands3[] = { Command::Command1, Command::Command2, Command::CommandCLOSEP,
Command::CommandCLOSEP, Command::CommandOPENP, Command::CommandNULL };
TestDriver::Test(L"12", L"(", commands3, true, true);
TestDriver::Test(L"12", L"12 \x00D7 (", commands3, true, true);
Command commands4[] = {
Command::Command2, Command::CommandOPENP, Command::Command2, Command::CommandCLOSEP, Command::CommandADD, Command::CommandNULL
};
TestDriver::Test(L"2", L"(2) + ", commands4, true, true);
TestDriver::Test(L"4", L"2 \x00D7 (2) + ", commands4, true, true);
Command commands5[] = { Command::Command2, Command::CommandOPENP, Command::Command2, Command::CommandCLOSEP,
Command::CommandADD, Command::CommandEQU, Command::CommandNULL };
TestDriver::Test(L"4", L"(2) + 2=", commands5, true, true);
TestDriver::Test(L"8", L"2 \x00D7 (2) + 4=", commands5, true, true);
}
void CalculatorManagerTest::CalculatorManagerTestScientificError()