mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 05:43:10 -07:00
Fix prefix 0s after deleting decimal point (#825)
This commit is contained in:
parent
a21b4a2d1a
commit
9e52256196
3 changed files with 25 additions and 0 deletions
|
@ -231,6 +231,10 @@ void CalcInput::Backspace()
|
|||
if (!m_base.IsEmpty())
|
||||
{
|
||||
m_base.value.pop_back();
|
||||
if (m_base.value == L"0")
|
||||
{
|
||||
m_base.value.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_base.value.size() <= m_decPtIndex)
|
||||
|
|
|
@ -184,6 +184,17 @@ namespace CalculatorUITests
|
|||
Assert.AreEqual("-1,234", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
// Issue #817: Prefixed multiple zeros
|
||||
[TestMethod]
|
||||
public void Operator_Delete_Prefix_Zeros()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(0.1); // To enter decimal point
|
||||
page.StandardOperators.BackSpaceButton.Click();
|
||||
page.StandardOperators.BackSpaceButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(0);
|
||||
Assert.AreEqual("0", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operator_ClearAll()
|
||||
{
|
||||
|
|
|
@ -252,6 +252,16 @@ namespace CalculatorEngineTests
|
|||
m_calcInput.Backspace();
|
||||
VERIFY_ARE_EQUAL(L"1.2", m_calcInput.ToString(10), L"Verify input after backspace.");
|
||||
}
|
||||
// Issue #817: Prefixed multiple zeros
|
||||
TEST_METHOD(BackspaceZeroDecimalWithoutPrefixZeros)
|
||||
{
|
||||
m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32);
|
||||
m_calcInput.TryAddDecimalPt();
|
||||
VERIFY_ARE_EQUAL(L"0.", m_calcInput.ToString(10), L"Verify input before backspace.")
|
||||
m_calcInput.Backspace();
|
||||
m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32);
|
||||
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10), L"Verify input after backspace.")
|
||||
}
|
||||
|
||||
TEST_METHOD(SetDecimalSymbol)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue