Updating code to append a wchar_t instead of const wchar_t (#778)

This commit is contained in:
Scott Freeman 2019-11-11 12:23:34 -05:00 committed by Matt Cooley
parent 4c81ed83c7
commit 01299a92cd
8 changed files with 27 additions and 30 deletions

View File

@ -179,7 +179,7 @@ bool CalcInput::TryAddDecimalPt()
if (m_base.IsEmpty())
{
m_base.value += L"0"; // Add a leading zero
m_base.value += L'0'; // Add a leading zero
}
m_decPtIndex = m_base.value.size();

View File

@ -640,9 +640,9 @@ namespace CalculationManager
if (pHistory)
{
pHistory->ClearHistory();
for (unsigned int i = 0; i < history.size(); ++i)
for (auto const& historyItem : history)
{
pHistory->AddItem(history[i]);
pHistory->AddItem(historyItem);
}
}
}

View File

@ -275,14 +275,12 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol)
wstring COpndCommand::GetString(uint32_t radix, int32_t precision)
{
wstring result{};
if (m_fInitialized)
{
result = m_value.ToString(radix, eNUMOBJ_FMT::FMT_FLOAT, precision);
return m_value.ToString(radix, eNUMOBJ_FMT::FMT_FLOAT, precision);
}
return result;
return wstring{};
}
void COpndCommand::Accept(_In_ ISerializeCommandVisitor& commandVisitor)

View File

@ -16,8 +16,7 @@ namespace CalcManager::NumberFormattingUtils
return;
}
wstring::iterator iter;
for (iter = number.end() - 1;; iter--)
for (auto iter = number.end() - 1;; iter--)
{
if (*iter != L'0')
{
@ -25,9 +24,9 @@ namespace CalcManager::NumberFormattingUtils
break;
}
}
if (*(number.end() - 1) == L'.')
if (number.back() == L'.')
{
number.erase(number.end() - 1, number.end());
number.pop_back();
}
}

View File

@ -401,43 +401,43 @@ void UnitConverter::SendCommand(Command command)
switch (command)
{
case Command::Zero:
m_currentDisplay += L"0";
m_currentDisplay += L'0';
break;
case Command::One:
m_currentDisplay += L"1";
m_currentDisplay += L'1';
break;
case Command::Two:
m_currentDisplay += L"2";
m_currentDisplay += L'2';
break;
case Command::Three:
m_currentDisplay += L"3";
m_currentDisplay += L'3';
break;
case Command::Four:
m_currentDisplay += L"4";
m_currentDisplay += L'4';
break;
case Command::Five:
m_currentDisplay += L"5";
m_currentDisplay += L'5';
break;
case Command::Six:
m_currentDisplay += L"6";
m_currentDisplay += L'6';
break;
case Command::Seven:
m_currentDisplay += L"7";
m_currentDisplay += L'7';
break;
case Command::Eight:
m_currentDisplay += L"8";
m_currentDisplay += L'8';
break;
case Command::Nine:
m_currentDisplay += L"9";
m_currentDisplay += L'9';
break;
case Command::Decimal:
@ -445,7 +445,7 @@ void UnitConverter::SendCommand(Command command)
clearBack = false;
if (!m_currentHasDecimal)
{
m_currentDisplay += L".";
m_currentDisplay += L'.';
m_currentHasDecimal = true;
}
break;

View File

@ -252,7 +252,7 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
if (yearCount > 0)
{
result += GetLocalizedNumberString(yearCount)->Data();
result += L" ";
result += L' ';
if (yearCount > 1)
{
@ -280,7 +280,7 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
}
result += GetLocalizedNumberString(monthCount)->Data();
result += L" ";
result += L' ';
if (monthCount > 1)
{
@ -305,7 +305,7 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
}
result += GetLocalizedNumberString(weekCount)->Data();
result += L" ";
result += L' ';
if (weekCount > 1)
{
@ -330,7 +330,7 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
}
result += GetLocalizedNumberString(dayCount)->Data();
result += L" ";
result += L' ';
if (dayCount > 1)
{
@ -348,7 +348,7 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
String ^ DateCalculatorViewModel::GetDateDiffStringInDays() const
{
wstring result = GetLocalizedNumberString(m_dateDiffResultInDays.day)->Data();
result += L" ";
result += L' ';
// Display the result as '1 day' or 'N days'
if (m_dateDiffResultInDays.day > 1)

View File

@ -309,7 +309,7 @@ namespace CalculatorEngineTests
wstring maxStr{};
for (size_t i = 0; i < MAX_STRLEN + 1; i++)
{
maxStr += L"1";
maxStr += L'1';
m_calcInput.TryAddDigit(1, 10, false, maxStr, 64, 100);
}
auto result = m_calcInput.ToString(10);
@ -323,7 +323,7 @@ namespace CalculatorEngineTests
bool exponentCapped = false;
for (size_t i = 0; i < MAX_STRLEN + 1; i++)
{
maxStr += L"1";
maxStr += L'1';
if (!m_calcInput.TryAddDigit(1, 10, false, maxStr, 64, MAX_STRLEN + 25))
{
exponentCapped = true;

View File

@ -67,7 +67,7 @@ namespace CalculatorUnitTests
StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown),
StringReference(exp_TooLong.c_str()),
L"Verify ValidatePasteExpression handles expressions up to max length");
exp_TooLong += L"1";
exp_TooLong += L'1';
VERIFY_ARE_EQUAL(
m_CopyPasteManager->ValidatePasteExpression(
StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, BitLength::BitLengthUnknown),