Accept exponential numbers without -/+ sign. (#270)

* add exponential without sign support

* Add unit tests

* fix formatting

* remove extra spaces

* modify unit tests
This commit is contained in:
Rudy Huyn
2019-05-09 10:10:17 -07:00
committed by Pepe Rivera
parent 9f01c8168b
commit 750130c2bc
4 changed files with 35 additions and 10 deletions

View File

@@ -187,8 +187,13 @@ namespace CalculatorUnitTests
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.");
m_CopyPasteManager.ExpressionRegExMatch(
vector<wstring>{ L"1.23e+456", L"1.23e456", L".23e+456", L"123e-456", L"12e2", L"12e+2", L"12e-2", L"-12e2", L"-12e+2", L"-12e-2" },
ViewMode::Scientific,
CategoryGroupType::Calculator,
-1,
-1),
L"Verify exponents are accepted in scientific mode.");
VERIFY_IS_FALSE(
m_CopyPasteManager.ExpressionRegExMatch(
@@ -647,9 +652,9 @@ namespace CalculatorUnitTests
"+(41213)",
"-(432+3232)",
"-(+(-3213)+(-2312))",
"-(-(432+3232))" };
String ^ negativeInput[] = { L"1.2e23" /*unsigned exponent*/,
L"abcdef",
"-(-(432+3232))",
L"1.2e23"/*unsigned exponent*/ };
String ^ negativeInput[] = { L"abcdef",
L"xyz",
L"ABab",
L"e+234",

View File

@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
@@ -419,6 +419,12 @@ namespace CalculatorUnitTests
m_viewModel->OnPaste("1.23e+10", ViewMode::Scientific);
ValidateViewModelValueAndExpression("1" + m_decimalSeparator + "23e+10", "");
m_viewModel->OnPaste("1.23e10", ViewMode::Scientific);
ValidateViewModelValueAndExpression("1" + m_decimalSeparator + "23e+10", "");
m_viewModel->OnPaste("135e10", ViewMode::Scientific);
ValidateViewModelValueAndExpression("135" + m_decimalSeparator + "e+10", "");
//// Negative exponent
m_viewModel->OnPaste("1.23e-10", ViewMode::Scientific);
ValidateViewModelValueAndExpression("1" + m_decimalSeparator + "23e-10", "");
@@ -426,6 +432,9 @@ namespace CalculatorUnitTests
//// Uppercase E (for exponent)
m_viewModel->OnPaste("1.23E-10", ViewMode::Scientific);
ValidateViewModelValueAndExpression("1" + m_decimalSeparator + "23e-10", "");
m_viewModel->OnPaste("135E10", ViewMode::Scientific);
ValidateViewModelValueAndExpression("135" + m_decimalSeparator + "e+10", "");
}
// Verify Calculator CalculationResultAutomationName is set correctly