mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-24 06:55:19 -07:00
add exponential without sign support
This commit is contained in:
parent
67fa2286eb
commit
3654ccd95b
3 changed files with 45 additions and 30 deletions
|
@ -45,7 +45,7 @@ static const array<wregex, 1> standardModePatterns =
|
|||
static const array<wregex, 2> scientificModePatterns =
|
||||
{
|
||||
wregex(c_wspcLParens + c_signedDecFloat + c_wspcRParens),
|
||||
wregex(c_wspcLParens + c_signedDecFloat + L"[e]([+]|[-])+\\d+" + c_wspcRParens)
|
||||
wregex(c_wspcLParens + c_signedDecFloat + L"e[+-]?\\d+" + c_wspcRParens)
|
||||
};
|
||||
static const array<array<wregex, 5>, 4> programmerModePatterns =
|
||||
{ {
|
||||
|
|
|
@ -855,14 +855,25 @@ void StandardCalculatorViewModel::OnPaste(String^ pastedString, ViewMode mode)
|
|||
}
|
||||
}
|
||||
|
||||
// Handle exponent and exponent sign (...e+... or ...e-...)
|
||||
// Handle exponent and exponent sign (...e+... or ...e-... or ...e...)
|
||||
if (mappedNumOp == NumbersAndOperatorsEnum::Exp)
|
||||
{
|
||||
++it;
|
||||
if (!(MapCharacterToButtonId(*it, canSendNegate) == NumbersAndOperatorsEnum::Add))
|
||||
//Check the following item
|
||||
switch (MapCharacterToButtonId(*(it + 1), canSendNegate))
|
||||
{
|
||||
case NumbersAndOperatorsEnum::Subtract:
|
||||
{
|
||||
Command cmdNegate = ConvertToOperatorsEnum(NumbersAndOperatorsEnum::Negate);
|
||||
m_standardCalculatorManager.SendCommand(cmdNegate);
|
||||
++it;
|
||||
}
|
||||
break;
|
||||
case NumbersAndOperatorsEnum::Add:
|
||||
{
|
||||
//Nothing to do, skip to the next item
|
||||
++it;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,10 @@ namespace CalculatorUnitTests
|
|||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123", L"1e23" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1));
|
||||
|
||||
VERIFY_IS_TRUE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"1.23e+456" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1), L"Verify operand only needs to match one pattern.");
|
||||
VERIFY_IS_TRUE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123e-456" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1), L"Verify operand only needs to match one pattern.");
|
||||
VERIFY_IS_TRUE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123e -456" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1), L"Verify operand only needs to match one pattern.");
|
||||
VERIFY_IS_TRUE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"12323e456" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1), L"Verify operand only needs to match one pattern.");
|
||||
VERIFY_IS_TRUE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"12323 e 456" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1), L"Verify operand only needs to match one pattern.");
|
||||
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123", L"12345678901234567" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), L"Verify all operands must be within maxlength");
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123", L"9223372036854775808" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, QwordType), L"Verify all operand must be within max value.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue