Build with /W4 (#197)

All projects are built with warning level 4 (/W4) and treat warnings as errors (/WX).
Fixed build errors resulting from enabling these compiler flags.
This commit is contained in:
Brett Waldbaum 2019-03-08 23:15:28 -08:00 committed by GitHub
parent e0f70e8c37
commit 64c6493312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 240 additions and 188 deletions

View File

@ -261,7 +261,7 @@ void CalcInput::SetDecimalSymbol(wchar_t decSymbol)
}
}
wstring CalcInput::ToString(uint32_t radix, bool isIntegerMode)
wstring CalcInput::ToString(uint32_t radix)
{
// In theory both the base and exponent could be C_NUM_MAX_DIGITS long.
wstringstream resStream;

View File

@ -223,11 +223,11 @@ void CHistoryCollector::AddUnaryOpToHistory(int nOpCode, bool fInv, ANGLE_TYPE a
{
angleOpCode = CalculationManager::Command::CommandDEG;
}
if (angletype == ANGLE_RAD)
else if (angletype == ANGLE_RAD)
{
angleOpCode = CalculationManager::Command::CommandRAD;
}
if (angletype == ANGLE_GRAD)
else // (angletype == ANGLE_GRAD)
{
angleOpCode = CalculationManager::Command::CommandGRAD;
}
@ -428,7 +428,7 @@ void CHistoryCollector::UpdateHistoryExpression(uint32_t radix, int32_t precisio
std::shared_ptr<COpndCommand> opndCommand = std::static_pointer_cast<COpndCommand>(expCommand);
if (opndCommand != nullptr)
{
token.first = opndCommand->GetString(radix, precision, m_decimalSymbol);
token.first = opndCommand->GetString(radix, precision);
IFT(m_spTokens->SetAt(i, token));
opndCommand->SetCommands(GetOperandCommandsFromString(token.first));
}

View File

@ -104,7 +104,7 @@ void CCalcEngine::DisplayNum(void)
if (m_bRecord)
{
// Display the string and return.
m_numberString = m_input.ToString(m_radix, m_fIntegerMode);
m_numberString = m_input.ToString(m_radix);
}
else
{

View File

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
class CalcException : std::exception
class CalcException : public std::exception
{
public:
CalcException(HRESULT hr)

View File

@ -155,6 +155,8 @@
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -169,6 +171,8 @@
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -183,6 +187,8 @@
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -197,6 +203,8 @@
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -212,6 +220,8 @@
<AdditionalOptions>/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -226,6 +236,8 @@
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -240,6 +252,8 @@
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -254,6 +268,8 @@
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -136,9 +136,6 @@
<ClInclude Include="Header Files\History.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Header Files\scimath.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="UnitConverter.h" />
<ClInclude Include="CalculatorHistory.h" />
<ClInclude Include="CalculatorManager.h" />

View File

@ -287,7 +287,7 @@ const wstring & COpndCommand::GetToken(wchar_t decimalSymbol)
return m_token;
}
wstring COpndCommand::GetString(uint32_t radix, int32_t precision, wchar_t decimalSymbol)
wstring COpndCommand::GetString(uint32_t radix, int32_t precision)
{
wstring result{};

View File

@ -67,7 +67,7 @@ public:
const std::wstring & GetToken(wchar_t decimalSymbol) override;
CalculationManager::CommandType GetCommandType() const override;
void Accept(_In_ ISerializeCommandVisitor &commandVisitor) override;
std::wstring GetString(uint32_t radix, int32_t precision, wchar_t decimalSymbol);
std::wstring GetString(uint32_t radix, int32_t precision);
private:
std::shared_ptr<CalculatorVector<int>> m_commands;

View File

@ -22,7 +22,7 @@ namespace CalcEngine
bool IsEmpty() { return value.empty(); }
bool IsNegative() { return m_isNegative; }
void IsNegative(bool value) { m_isNegative = value; }
void IsNegative(bool isNegative) { m_isNegative = isNegative; }
std::wstring value;
@ -53,7 +53,7 @@ namespace CalcEngine
bool TryBeginExponent();
void Backspace();
void SetDecimalSymbol(wchar_t decSymbol);
std::wstring ToString(uint32_t radix, bool isIntegerMode);
std::wstring ToString(uint32_t radix);
Rational ToRational(uint32_t radix, int32_t precision);
private:

View File

@ -566,7 +566,7 @@ wchar_t NormalizeCharDigit(wchar_t c, uint32_t radix)
// is in the range where this is not ambiguous.
if (size_t{ radix } >= DIGITS.find(L'A') && size_t { radix } <= DIGITS.find(L'Z'))
{
return toupper(c);
return towupper(c);
}
return c;
@ -1057,10 +1057,6 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
length = precision;
}
// 2 for signs, 1 for 'e'(or leading zero), 1 for dp, 1 for null and
// 10 for maximum exponent size.
int cchNum = (precision + 16);
// If there is a chance a round has to occur, round.
// - if number is zero no rounding
// - if number of digits is less than the maximum output no rounding

View File

@ -38,7 +38,7 @@ using namespace std;
//
//-----------------------------------------------------------------------------
void gcdrat( PRAT *pa, uint32_t radix, int32_t precision)
void gcdrat( PRAT *pa, int32_t precision)
{
PNUMBER pgcd= nullptr;

View File

@ -424,7 +424,7 @@ extern void divrat( _Inout_ PRAT *pa, _In_ PRAT b, int32_t precision);
extern void fracrat( _Inout_ PRAT *pa , uint32_t radix, int32_t precision);
extern void factrat( _Inout_ PRAT *pa, uint32_t radix, int32_t precision);
extern void modrat( _Inout_ PRAT *pa, _In_ PRAT b );
extern void gcdrat( _Inout_ PRAT *pa, uint32_t radix, int32_t precision);
extern void gcdrat( _Inout_ PRAT *pa, int32_t precision);
extern void intrat( _Inout_ PRAT *px, uint32_t radix, int32_t precision);
extern void mulnum( _Inout_ PNUMBER *pa, _In_ PNUMBER b, uint32_t radix);
extern void mulnumx( _Inout_ PNUMBER *pa, _In_ PNUMBER b );

View File

@ -154,6 +154,8 @@
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4453</DisableSpecificWarnings>
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -172,6 +174,8 @@
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4453</DisableSpecificWarnings>
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -190,6 +194,8 @@
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4453</DisableSpecificWarnings>
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -208,6 +214,8 @@
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4453</DisableSpecificWarnings>
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -226,6 +234,8 @@
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4453</DisableSpecificWarnings>
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -244,6 +254,8 @@
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4453</DisableSpecificWarnings>
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -262,6 +274,8 @@
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4453</DisableSpecificWarnings>
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -280,6 +294,8 @@
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4453</DisableSpecificWarnings>
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -15,7 +15,6 @@ using namespace Windows::Foundation;
using namespace Windows::System;
using namespace Windows::ApplicationModel::DataTransfer;
size_t maxOperandLength;
unsigned long long maxOperandNumber;
String^ CopyPasteManager::supportedFormats[] =
@ -533,7 +532,7 @@ size_t CopyPasteManager::ProgrammerOperandLength(const wstring& operand, int num
suffixes.insert(suffixes.end(), uintSuffixes.begin(), uintSuffixes.end());
wstring operandUpper = operand;
transform(operandUpper.begin(), operandUpper.end(), operandUpper.begin(), toupper);
transform(operandUpper.begin(), operandUpper.end(), operandUpper.begin(), towupper);
// Detect if there is a suffix and subtract its length
// Check suffixes first to allow e.g. "0b" to result in length 1 (value 0), rather than length 0 (no value).

View File

@ -43,7 +43,6 @@ static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeyControlS
static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeyInverseChordsForButtons;
static multimap<int, multimap<MyVirtualKey, WeakReference>> s_VirtualKeyControlInverseChordsForButtons;
static const TimeSpan c_lightUpTime = { 500000 }; // Quarter of a second
static multimap<int, bool> s_ShiftKeyPressed;
static multimap<int, bool> s_ControlKeyPressed;
static multimap<int, bool> s_ShiftButtonChecked;
@ -83,11 +82,13 @@ namespace CalculatorApp
// The button will go into the visual Pressed state with this call
VisualStateManager::GoToState(button, "Pressed", true);
// This timer will fire after c_lightUpTime and make the button
// This timer will fire after lightUpTime and make the button
// go back to the normal state.
// This timer will only fire once after which it will be destroyed
auto timer = ref new DispatcherTimer();
timer->Interval = c_lightUpTime;
TimeSpan lightUpTime{};
lightUpTime.Duration = 500000L; // Half second (in 100-ns units)
timer->Interval = lightUpTime;
WeakReference timerWeakReference(timer);
WeakReference buttonWeakReference(button);
@ -579,9 +580,9 @@ void KeyboardShortcutManager::OnKeyDownHandler(CoreWindow^ sender, KeyEventArgs^
// Writer lock for the static maps
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
auto currentControlKeyPressed = s_ControlKeyPressed.find(viewId);
auto currControlKeyPressed = s_ControlKeyPressed.find(viewId);
if (currentControlKeyPressed != s_ControlKeyPressed.end())
if (currControlKeyPressed != s_ControlKeyPressed.end())
{
s_ControlKeyPressed.erase(viewId);
s_ControlKeyPressed.insert(std::make_pair(viewId, true));
@ -593,9 +594,9 @@ void KeyboardShortcutManager::OnKeyDownHandler(CoreWindow^ sender, KeyEventArgs^
// Writer lock for the static maps
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
auto currentShiftKeyPressed = s_ShiftKeyPressed.find(viewId);
auto currShiftKeyPressed = s_ShiftKeyPressed.find(viewId);
if (currentShiftKeyPressed != s_ShiftKeyPressed.end())
if (currShiftKeyPressed != s_ShiftKeyPressed.end())
{
s_ShiftKeyPressed.erase(viewId);
s_ShiftKeyPressed.insert(std::make_pair(viewId, true));
@ -636,7 +637,7 @@ void KeyboardShortcutManager::OnKeyUpHandler(CoreWindow^ sender, KeyEventArgs^ a
int viewId = Utils::GetWindowId();
auto key = args->VirtualKey;
if (args->VirtualKey == VirtualKey::Shift)
if (key == VirtualKey::Shift)
{
// Writer lock for the static maps
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
@ -649,14 +650,14 @@ void KeyboardShortcutManager::OnKeyUpHandler(CoreWindow^ sender, KeyEventArgs^ a
s_ShiftKeyPressed.insert(std::make_pair(viewId, false));
}
}
else if (args->VirtualKey == VirtualKey::Control)
else if (key == VirtualKey::Control)
{
// Writer lock for the static maps
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
auto currentControlKeyPressed = s_ControlKeyPressed.find(viewId);
auto currControlKeyPressed = s_ControlKeyPressed.find(viewId);
if (currentControlKeyPressed != s_ControlKeyPressed.end())
if (currControlKeyPressed != s_ControlKeyPressed.end())
{
s_ControlKeyPressed.erase(viewId);
s_ControlKeyPressed.insert(std::make_pair(viewId, false));

View File

@ -176,7 +176,7 @@ namespace CalculatorApp
{
iterMap->second.insert(iterMap->second.begin(), L"Programmer");
}
else
else if (isStandard)
{
iterMap->second.insert(iterMap->second.begin(), L"Standard");
}
@ -199,7 +199,7 @@ namespace CalculatorApp
{
iterMap->second[memoryPosition] = L"Programmer";
}
else
else if (isStandard)
{
iterMap->second[memoryPosition] = L"Standard";
}
@ -872,6 +872,7 @@ namespace CalculatorApp
if (!m_dateDiffUsageLoggedInSession)
{
LoggingFields fields{};
fields.AddUInt32(L"WindowId", windowId);
LogTelemetryEvent(EVENT_NAME_DATE_DIFFERENCE_USED, fields);
m_dateDiffUsageLoggedInSession = true;

View File

@ -291,7 +291,6 @@ void HistoryViewModel::SaveHistory()
// this serializes a history item into a base64 encoded string
Platform::String^ HistoryViewModel::SerializeHistoryItem(_In_ std::shared_ptr<CalculationManager::HISTORYITEM> const &item)
{
HRESULT hr = S_OK;
DataWriter^ writer = ref new DataWriter();
auto expr = item->historyItemVector.expression;
auto result = item->historyItemVector.result;

View File

@ -178,7 +178,6 @@ String^ StandardCalculatorViewModel::CalculateNarratorDisplayValue(_In_ wstring
String^ StandardCalculatorViewModel::GetNarratorStringReadRawNumbers(_In_ String^ localizedDisplayValue)
{
wstringstream wss;
RADIX_TYPE radix = static_cast<RADIX_TYPE>(CurrentRadixType);
auto& locSettings = LocalizationSettings::GetInstance();
// Insert a space after each digit in the string, to force Narrator to read them as separate numbers.
@ -426,50 +425,50 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
displayExpressionToken->CommandIndex = 0;
}
wchar_t ch;
wchar_t ch = 0;
if ((cmdenum >= Command::Command0) && (cmdenum <= Command::Command9))
{
switch (cmdenum)
{
case Command::Command0:
ch = '0';
ch = L'0';
break;
case Command::Command1:
ch = '1';
ch = L'1';
break;
case Command::Command2:
ch = '2';
ch = L'2';
break;
case Command::Command3:
ch = '3';
ch = L'3';
break;
case Command::Command4:
ch = '4';
ch = L'4';
break;
case Command::Command5:
ch = '5';
ch = L'5';
break;
case Command::Command6:
ch = '6';
ch = L'6';
break;
case Command::Command7:
ch = '7';
ch = L'7';
break;
case Command::Command8:
ch = '8';
ch = L'8';
break;
case Command::Command9:
ch = '9';
ch = L'9';
break;
}
}
else if (cmdenum == Command::CommandPNT)
{
ch = '.';
ch = L'.';
}
else if (cmdenum == Command::CommandBACK)
{
ch = 'x';
ch = L'x';
}
else
{
@ -486,7 +485,7 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
{
//Clear older text;
m_selectedExpressionLastData = L"";
if (ch == 'x')
if (ch == L'x')
{
temp[0] = L'\0';
commandIndex = 0;
@ -501,7 +500,7 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
}
else
{
if (ch == 'x')
if (ch == L'x')
{
if (commandIndex == 0)
{
@ -518,7 +517,7 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
}
temp[i++] = data[j];
}
temp[i] = '\0';
temp[i] = L'\0';
commandIndex -= 1;
}
else
@ -537,7 +536,7 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
}
temp[i] = data[j++];
}
temp[i] = '\0';
temp[i] = L'\0';
commandIndex += 1;
}
}
@ -567,7 +566,6 @@ void StandardCalculatorViewModel::OnButtonPressed(Object^ parameter)
m_feedbackForButtonPress = CalculatorButtonPressedEventArgs::GetAuditoryFeedbackFromCommandParameter(parameter);
NumbersAndOperatorsEnum numOpEnum = CalculatorButtonPressedEventArgs::GetOperationFromCommandParameter(parameter);
Command cmdenum = ConvertToOperatorsEnum(numOpEnum);
bool isOperator = IsOperator(cmdenum);
TraceLogger::GetInstance().UpdateFunctionUsage((int)numOpEnum);
@ -748,7 +746,6 @@ void StandardCalculatorViewModel::OnPaste(String^ pastedString, ViewMode mode)
bool isFirstLegalChar = true;
m_standardCalculatorManager.SendCommand(Command::CommandCENTR);
bool sendNegate = false;
bool processedExp = false;
bool processedDigit = false;
bool sentEquals = false;
bool isPreviousOperator = false;
@ -1371,7 +1368,6 @@ ANGLE_TYPE GetAngleTypeFromCommand(Command command)
void StandardCalculatorViewModel::SaveEditedCommand(_In_ unsigned int tokenPosition, _In_ Command command)
{
pair<wstring, int> token;
bool fNegative = false;
bool handleOperand = false;
int nOpCode = static_cast<int>(command);
wstring updatedToken = L"";

View File

@ -141,6 +141,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 </AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
@ -148,6 +150,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 </AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
@ -155,6 +159,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>WindowsApp.lib;$(VC_ReferencesPath_VC_ARM)\pgort.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -165,6 +171,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>WindowsApp.lib;$(VC_ReferencesPath_VC_ARM)\pgort.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -175,6 +183,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 </AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -182,6 +192,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>WindowsApp.lib;$(VC_ReferencesPath_VC_x86)\pgort.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -192,6 +204,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 </AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -199,6 +213,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>WindowsApp.lib;$(VC_ReferencesPath_VC_x64)\pgort.lib;%(AdditionalDependencies)</AdditionalDependencies>

View File

@ -118,17 +118,17 @@ void CalculationResult::OnTextContainerLayoutUpdated(Object^ /*sender*/, Object^
}
}
void CalculationResult::TextContainerSizeChanged(Object^ sender, SizeChangedEventArgs^ /*e*/)
void CalculationResult::TextContainerSizeChanged(Object^ /*sender*/, SizeChangedEventArgs^ /*e*/)
{
UpdateTextState();
}
void CalculationResult::OnIsActivePropertyChanged(bool /*oldValue*/, bool newValue)
void CalculationResult::OnIsActivePropertyChanged(bool /*oldValue*/, bool /*newValue */)
{
UpdateVisualState();
}
void CalculationResult::OnAccentColorPropertyChanged(Brush^ oldValue, Brush^ newValue)
void CalculationResult::OnAccentColorPropertyChanged(Brush^ /*oldValue*/, Brush^ /*newValue*/)
{
// Force the "Active" transition to happen again
if (IsActive)

View File

@ -277,7 +277,7 @@ void Calculator::OnLayoutStateChanged(_In_ Object^ sender, _In_ Object^ e)
UpdatePanelViewState();
}
void Calculator::OnIsStandardPropertyChanged(bool /*oldValue*/, bool newValue)
void Calculator::OnIsStandardPropertyChanged(bool /*oldValue*/, bool /*newValue*/)
{
UpdateViewState();
UpdatePanelViewState();

View File

@ -31,18 +31,18 @@ namespace CalculatorUnitTests
m_calcInput.TryBeginExponent();
m_calcInput.TryAddDigit(3, 10, false, L"999", 64, 32);
VERIFY_ARE_EQUAL(L"-1.2e+3", m_calcInput.ToString(10, false), L"Verify input is correct.");
VERIFY_ARE_EQUAL(L"-1.2e+3", m_calcInput.ToString(10), L"Verify input is correct.");
m_calcInput.Clear();
::Logger::WriteMessage(m_calcInput.ToString(10, false).c_str());
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10, false), L"Verify input is 0 after clear.");
::Logger::WriteMessage(m_calcInput.ToString(10).c_str());
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10), L"Verify input is 0 after clear.");
}
TEST_METHOD(TryToggleSignZero)
{
VERIFY_IS_TRUE(m_calcInput.TryToggleSign(false, L"999"), L"Verify toggling 0 succeeds.");
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10, false), L"Verify toggling 0 does not create -0.");
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10), L"Verify toggling 0 does not create -0.");
}
TEST_METHOD(TryToggleSignExponent)
{
@ -50,23 +50,23 @@ namespace CalculatorUnitTests
m_calcInput.TryBeginExponent();
m_calcInput.TryAddDigit(2, 10, false, L"999", 64, 32);
VERIFY_IS_TRUE(m_calcInput.TryToggleSign(false, L"999"), L"Verify toggling exponent sign succeeds.");
VERIFY_ARE_EQUAL(L"1.e-2", m_calcInput.ToString(10, false), L"Verify toggling exponent sign does not toggle base sign.");
VERIFY_ARE_EQUAL(L"1.e-2", m_calcInput.ToString(10), L"Verify toggling exponent sign does not toggle base sign.");
VERIFY_IS_TRUE(m_calcInput.TryToggleSign(false, L"999"), L"Verify toggling exponent sign succeeds.");
VERIFY_ARE_EQUAL(L"1.e+2", m_calcInput.ToString(10, false), L"Verify toggling negative exponent sign does not toggle base sign.");
VERIFY_ARE_EQUAL(L"1.e+2", m_calcInput.ToString(10), L"Verify toggling negative exponent sign does not toggle base sign.");
}
TEST_METHOD(TryToggleSignBase)
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
VERIFY_IS_TRUE(m_calcInput.TryToggleSign(false, L"999"), L"Verify toggling base sign succeeds.");
VERIFY_ARE_EQUAL(L"-1", m_calcInput.ToString(10, false), L"Verify toggling base sign creates negative base.");
VERIFY_ARE_EQUAL(L"-1", m_calcInput.ToString(10), L"Verify toggling base sign creates negative base.");
VERIFY_IS_TRUE(m_calcInput.TryToggleSign(false, L"999"), L"Verify toggling base sign succeeds.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10, false), L"Verify toggling negative base sign creates positive base.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10), L"Verify toggling negative base sign creates positive base.");
}
TEST_METHOD(TryToggleSignBaseIntegerMode)
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
VERIFY_IS_TRUE(m_calcInput.TryToggleSign(true, L"999"), L"Verify toggling base sign in integer mode succeeds.");
VERIFY_ARE_EQUAL(L"-1", m_calcInput.ToString(10, false), L"Verify toggling base sign creates negative base.");
VERIFY_ARE_EQUAL(L"-1", m_calcInput.ToString(10), L"Verify toggling base sign creates negative base.");
}
TEST_METHOD(TryToggleSignRollover)
{
@ -75,7 +75,7 @@ namespace CalculatorUnitTests
VERIFY_IS_TRUE(m_calcInput.TryToggleSign(true, L"127"), L"Verify toggling base sign in integer mode succeeds.");
m_calcInput.TryAddDigit(8, 10, false, L"999", 64, 32);
VERIFY_IS_FALSE(m_calcInput.TryToggleSign(true, L"127"), L"Verify toggling base sign in integer mode fails on rollover.");
VERIFY_ARE_EQUAL(L"-128", m_calcInput.ToString(10, false), L"Verify toggling base sign on rollover does not change value.");
VERIFY_ARE_EQUAL(L"-128", m_calcInput.ToString(10), L"Verify toggling base sign on rollover does not change value.");
}
TEST_METHOD(TryAddDigitLeadingZeroes)
@ -83,26 +83,26 @@ namespace CalculatorUnitTests
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32), L"Verify TryAddDigit succeeds.");
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32), L"Verify TryAddDigit succeeds.");
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(0, 10, false, L"999", 64, 32), L"Verify TryAddDigit succeeds.");
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10, false), L"Verify leading zeros are ignored.");
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10), L"Verify leading zeros are ignored.");
}
TEST_METHOD(TryAddDigitMaxCount)
{
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32), L"Verify TryAddDigit for base with length < maxDigits succeeds.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10, false), L"Verify adding digit for base with length < maxDigits succeeded.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10), L"Verify adding digit for base with length < maxDigits succeeded.");
VERIFY_IS_FALSE(m_calcInput.TryAddDigit(2, 10, false, L"999", 64, 1), L"Verify TryAddDigit for base with length > maxDigits fails.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10, false), L"Verify digit for base was not added.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10), L"Verify digit for base was not added.");
m_calcInput.TryBeginExponent();
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32), L"Verify TryAddDigit for exponent with length < maxDigits succeeds.");
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(2, 10, false, L"999", 64, 32), L"Verify TryAddDigit for exponent with length < maxDigits succeeds.");
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(3, 10, false, L"999", 64, 32), L"Verify TryAddDigit for exponent with length < maxDigits succeeds.");
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(4, 10, false, L"999", 64, 32), L"Verify TryAddDigit for exponent with length < maxDigits succeeds.");
VERIFY_IS_FALSE(m_calcInput.TryAddDigit(5, 10, false, L"999", 64, 32), L"Verify TryAddDigit for exponent with length > maxDigits fails.");
VERIFY_ARE_EQUAL(L"1.e+1234", m_calcInput.ToString(10, false), L"Verify adding digits for exponent with length < maxDigits succeeded.");
VERIFY_ARE_EQUAL(L"1.e+1234", m_calcInput.ToString(10), L"Verify adding digits for exponent with length < maxDigits succeeded.");
m_calcInput.Clear();
m_calcInput.TryAddDecimalPt();
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 1), L"Verify decimal point and leading zero does not count toward maxDigits.");
VERIFY_ARE_EQUAL(L"0.1", m_calcInput.ToString(10, false), L"Verify input value checking dec pt and leading zero impact on maxDigits.");
VERIFY_ARE_EQUAL(L"0.1", m_calcInput.ToString(10), L"Verify input value checking dec pt and leading zero impact on maxDigits.");
}
TEST_METHOD(TryAddDigitValues)
{
@ -181,7 +181,7 @@ namespace CalculatorUnitTests
VERIFY_IS_FALSE(m_calcInput.HasDecimalPt(), L"Verify input has no decimal point.");
VERIFY_IS_TRUE(m_calcInput.TryAddDecimalPt(), L"Verify adding decimal to empty input.");
VERIFY_IS_TRUE(m_calcInput.HasDecimalPt(), L"Verify input has decimal point.");
VERIFY_ARE_EQUAL(L"0.", m_calcInput.ToString(10, false), L"Verify decimal on empty input.");
VERIFY_ARE_EQUAL(L"0.", m_calcInput.ToString(10), L"Verify decimal on empty input.");
}
TEST_METHOD(TryAddDecimalPointTwice)
{
@ -202,7 +202,7 @@ namespace CalculatorUnitTests
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
VERIFY_IS_TRUE(m_calcInput.TryBeginExponent(), L"Verify adding exponent succeeds on input without exponent.");
VERIFY_ARE_EQUAL(L"1.e+0", m_calcInput.ToString(10, false), L"Verify exponent present.");
VERIFY_ARE_EQUAL(L"1.e+0", m_calcInput.ToString(10), L"Verify exponent present.");
}
TEST_METHOD(TryBeginExponentWithExponent)
{
@ -214,31 +214,31 @@ namespace CalculatorUnitTests
TEST_METHOD(BackspaceZero)
{
m_calcInput.Backspace();
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10, false), L"Verify backspace on 0 is still 0.");
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10), L"Verify backspace on 0 is still 0.");
}
TEST_METHOD(BackspaceSingleChar)
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10, false), L"Verify input before backspace.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10), L"Verify input before backspace.");
m_calcInput.Backspace();
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10, false), L"Verify input after backspace.");
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10), L"Verify input after backspace.");
}
TEST_METHOD(BackspaceMultiChar)
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
m_calcInput.TryAddDigit(2, 10, false, L"999", 64, 32);
VERIFY_ARE_EQUAL(L"12", m_calcInput.ToString(10, false), L"Verify input before backspace.");
VERIFY_ARE_EQUAL(L"12", m_calcInput.ToString(10), L"Verify input before backspace.");
m_calcInput.Backspace();
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10, false), L"Verify input after backspace.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10), L"Verify input after backspace.");
}
TEST_METHOD(BackspaceDecimal)
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
m_calcInput.TryAddDecimalPt();
VERIFY_ARE_EQUAL(L"1.", m_calcInput.ToString(10, false), L"Verify input before backspace.");
VERIFY_ARE_EQUAL(L"1.", m_calcInput.ToString(10), L"Verify input before backspace.");
VERIFY_IS_TRUE(m_calcInput.HasDecimalPt(), L"Verify input has decimal point.");
m_calcInput.Backspace();
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10, false), L"Verify input after backspace.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10), L"Verify input after backspace.");
VERIFY_IS_FALSE(m_calcInput.HasDecimalPt(), L"Verify decimal point was removed.");
}
TEST_METHOD(BackspaceMultiCharDecimal)
@ -247,47 +247,47 @@ namespace CalculatorUnitTests
m_calcInput.TryAddDecimalPt();
m_calcInput.TryAddDigit(2, 10, false, L"999", 64, 32);
m_calcInput.TryAddDigit(3, 10, false, L"999", 64, 32);
VERIFY_ARE_EQUAL(L"1.23", m_calcInput.ToString(10, false), L"Verify input before backspace.");
VERIFY_ARE_EQUAL(L"1.23", m_calcInput.ToString(10), L"Verify input before backspace.");
m_calcInput.Backspace();
VERIFY_ARE_EQUAL(L"1.2", m_calcInput.ToString(10, false), L"Verify input after backspace.");
VERIFY_ARE_EQUAL(L"1.2", m_calcInput.ToString(10), L"Verify input after backspace.");
}
TEST_METHOD(SetDecimalSymbol)
{
m_calcInput.TryAddDecimalPt();
VERIFY_ARE_EQUAL(L"0.", m_calcInput.ToString(10, false), L"Verify default decimal point.");
VERIFY_ARE_EQUAL(L"0.", m_calcInput.ToString(10), L"Verify default decimal point.");
m_calcInput.SetDecimalSymbol(L',');
VERIFY_ARE_EQUAL(L"0,", m_calcInput.ToString(10, false), L"Verify new decimal point.");
VERIFY_ARE_EQUAL(L"0,", m_calcInput.ToString(10), L"Verify new decimal point.");
}
TEST_METHOD(ToStringEmpty)
{
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10, false), L"Verify ToString of empty value.");
VERIFY_ARE_EQUAL(L"0", m_calcInput.ToString(10), L"Verify ToString of empty value.");
}
TEST_METHOD(ToStringNegative)
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
m_calcInput.TryToggleSign(false, L"999");
VERIFY_ARE_EQUAL(L"-1", m_calcInput.ToString(10, false), L"Verify ToString of negative value.");
VERIFY_ARE_EQUAL(L"-1", m_calcInput.ToString(10), L"Verify ToString of negative value.");
}
TEST_METHOD(ToStringExponentBase10)
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
m_calcInput.TryBeginExponent();
VERIFY_ARE_EQUAL(L"1.e+0", m_calcInput.ToString(10, false), L"Verify ToString of empty base10 exponent.");
VERIFY_ARE_EQUAL(L"1.e+0", m_calcInput.ToString(10), L"Verify ToString of empty base10 exponent.");
}
TEST_METHOD(ToStringExponentBase8)
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
m_calcInput.TryBeginExponent();
VERIFY_ARE_EQUAL(L"1.^+0", m_calcInput.ToString(8, false), L"Verify ToString of empty base8 exponent.");
VERIFY_ARE_EQUAL(L"1.^+0", m_calcInput.ToString(8), L"Verify ToString of empty base8 exponent.");
}
TEST_METHOD(ToStringExponentNegative)
{
m_calcInput.TryAddDigit(1, 8, false, L"999", 64, 32);
m_calcInput.TryBeginExponent();
m_calcInput.TryToggleSign(false, L"999");
VERIFY_ARE_EQUAL(L"1.e-0", m_calcInput.ToString(10, false), L"Verify ToString of empty negative exponent.");
VERIFY_ARE_EQUAL(L"1.e-0", m_calcInput.ToString(10), L"Verify ToString of empty negative exponent.");
}
TEST_METHOD(ToStringExponentPositive)
{
@ -296,12 +296,12 @@ namespace CalculatorUnitTests
m_calcInput.TryAddDigit(2, 10, false, L"999", 64, 32);
m_calcInput.TryAddDigit(3, 10, false, L"999", 64, 32);
m_calcInput.TryAddDigit(4, 10, false, L"999", 64, 32);
VERIFY_ARE_EQUAL(L"1.e+234", m_calcInput.ToString(10, false), L"Verify ToString of exponent with value.");
VERIFY_ARE_EQUAL(L"1.e+234", m_calcInput.ToString(10), L"Verify ToString of exponent with value.");
}
TEST_METHOD(ToStringInteger)
{
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10, true), L"Verify ToString of integer value hides decimal.");
VERIFY_ARE_EQUAL(L"1", m_calcInput.ToString(10), L"Verify ToString of integer value hides decimal.");
}
TEST_METHOD(ToStringBaseTooLong)
{
@ -311,7 +311,7 @@ namespace CalculatorUnitTests
maxStr += L"1";
m_calcInput.TryAddDigit(1, 10, false, maxStr, 64, 100);
}
auto result = m_calcInput.ToString(10, false);
auto result = m_calcInput.ToString(10);
VERIFY_IS_TRUE(result.empty(), L"Verify ToString of base value that is too large yields empty string.");
}
TEST_METHOD(ToStringExponentTooLong)
@ -328,7 +328,7 @@ namespace CalculatorUnitTests
exponentCapped = true;
}
}
auto result = m_calcInput.ToString(10, false);
auto result = m_calcInput.ToString(10);
// TryAddDigit caps the exponent length to C_EXP_MAX_DIGITS = 4, so ToString() succeeds.
// If that cap is removed, ToString() should return an empty string.
@ -347,7 +347,7 @@ namespace CalculatorUnitTests
m_calcInput.TryAddDigit(1, 10, false, L"999", 64, 32);
m_calcInput.TryAddDigit(2, 10, false, L"999", 64, 32);
m_calcInput.TryAddDigit(3, 10, false, L"999", 64, 32);
VERIFY_ARE_EQUAL(L"123", m_calcInput.ToString(10, false), L"Verify input before conversion to rational.");
VERIFY_ARE_EQUAL(L"123", m_calcInput.ToString(10), L"Verify input before conversion to rational.");
auto rat = m_calcInput.ToRational(10, false);
VERIFY_ARE_EQUAL(1, rat.P().Mantissa().size(), L"Verify digit count of rational.");

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"
@ -40,7 +40,7 @@ namespace CalculatorManagerTest
{
m_isError = isError;
}
void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const &commands)
void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const & /*commands*/)
{
m_expression.clear();
unsigned int nTokens = 0;
@ -79,7 +79,7 @@ namespace CalculatorManagerTest
return m_isError;
}
void OnHistoryItemAdded(_In_ unsigned int addedItemIndex)
void OnHistoryItemAdded(_In_ unsigned int /*addedItemIndex */)
{
}
@ -98,7 +98,7 @@ namespace CalculatorManagerTest
m_binaryOperatorReceivedCallCount++;
}
void MemoryItemChanged(unsigned int indexOfMemory)
void MemoryItemChanged(unsigned int /*indexOfMemory*/)
{
}

View File

@ -137,6 +137,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)CalcManager;$(SolutionDir)CalcViewModel;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
@ -144,6 +146,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)CalcManager;$(SolutionDir)CalcViewModel;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
@ -151,6 +155,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)CalcManager;$(SolutionDir)CalcViewModel;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
@ -158,6 +164,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)CalcManager;$(SolutionDir)CalcViewModel;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -165,6 +173,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)CalcManager;$(SolutionDir)CalcViewModel;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -172,6 +182,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)CalcManager;$(SolutionDir)CalcViewModel;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -179,6 +191,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)CalcManager;$(SolutionDir)CalcViewModel;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -186,6 +200,8 @@
<AdditionalOptions>/bigobj /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)CalcManager;$(SolutionDir)CalcViewModel;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>

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"
@ -74,15 +74,15 @@ public:
m_task_completion_event{ tce }
{}
void CurrencyDataLoadFinished(bool didLoad) override
void CurrencyDataLoadFinished(bool /*didLoad*/) override
{
m_task_completion_event.set();
}
void CurrencySymbolsCallback(_In_ const wstring& fromSymbol, _In_ const wstring& toSymbol) override {}
void CurrencyRatiosCallback(_In_ const wstring& ratioEquality, _In_ const wstring& accRatioEquality) override {}
void CurrencyTimestampCallback(_In_ const std::wstring& timestamp, bool isWeekOldData) override {}
void NetworkBehaviorChanged(_In_ int newBehavior) override {}
void CurrencySymbolsCallback(_In_ const wstring& /*fromSymbol*/, _In_ const wstring& /*toSymbol*/) override {}
void CurrencyRatiosCallback(_In_ const wstring& /*ratioEquality*/, _In_ const wstring& /*accRatioEquality*/) override {}
void CurrencyTimestampCallback(_In_ const std::wstring& /*timestamp*/, bool /*isWeekOldData*/) override {}
void NetworkBehaviorChanged(_In_ int /*newBehavior*/) override {}
private:
Concurrency::task_completion_event<void> m_task_completion_event;
@ -407,11 +407,11 @@ namespace CalculatorUnitTests
const UCM::Unit usdUnit = GetUnit(unitList, L"USD");
const UCM::Unit eurUnit = GetUnit(unitList, L"EUR");
VERIFY_ARE_EQUAL(StringReference(L"United States - Dollar"), ref new String(usdUnit.name.c_str()));
VERIFY_ARE_EQUAL(StringReference(L"USD"), ref new String(usdUnit.abbreviation.c_str()));
VERIFY_ARE_EQUAL(wstring(L"United States - Dollar"), usdUnit.name);
VERIFY_ARE_EQUAL(wstring(L"USD"), usdUnit.abbreviation);
VERIFY_ARE_EQUAL(StringReference(L"Europe - Euro"), ref new String(eurUnit.name.c_str()));
VERIFY_ARE_EQUAL(StringReference(L"EUR"), ref new String(eurUnit.abbreviation.c_str()));
VERIFY_ARE_EQUAL(wstring(L"Europe - Euro"), eurUnit.name);
VERIFY_ARE_EQUAL(wstring(L"EUR"), eurUnit.abbreviation);
}
TEST_METHOD(Loaded_LoadOrderedRatios)
@ -472,8 +472,8 @@ namespace CalculatorUnitTests
const pair<wstring, wstring> symbols = loader.GetCurrencySymbols(usdUnit, eurUnit);
VERIFY_ARE_EQUAL(ref new String(L"$"), StringReference(symbols.first.c_str()));
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(symbols.second.c_str()));
VERIFY_ARE_EQUAL(wstring(L"$"), symbols.first);
VERIFY_ARE_EQUAL(wstring(L"\x20ac"), symbols.second); // €
}
TEST_METHOD(Loaded_GetCurrencySymbols_Invalid)
@ -503,8 +503,8 @@ namespace CalculatorUnitTests
pair<wstring, wstring> symbols = loader.GetCurrencySymbols(fakeUnit1, fakeUnit2);
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(symbols.first.c_str()));
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(symbols.second.c_str()));
VERIFY_ARE_EQUAL(wstring(L""), wstring(symbols.first.c_str()));
VERIFY_ARE_EQUAL(wstring(L""), wstring(symbols.second.c_str()));
// Verify that when only one unit is valid, both symbols return as empty string.
vector<UCM::Unit> unitList = loader.LoadOrderedUnits(CURRENCY_CATEGORY);
@ -514,13 +514,13 @@ namespace CalculatorUnitTests
symbols = loader.GetCurrencySymbols(fakeUnit1, usdUnit);
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(symbols.first.c_str()));
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(symbols.second.c_str()));
VERIFY_ARE_EQUAL(wstring(L""), symbols.first);
VERIFY_ARE_EQUAL(wstring(L""), symbols.second);
symbols = loader.GetCurrencySymbols(usdUnit, fakeUnit1);
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(symbols.first.c_str()));
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(symbols.second.c_str()));
VERIFY_ARE_EQUAL(wstring(L""), symbols.first);
VERIFY_ARE_EQUAL(wstring(L""), symbols.second);
}
TEST_METHOD(Loaded_GetCurrencyRatioEquality_Valid)
@ -548,8 +548,8 @@ namespace CalculatorUnitTests
const pair<wstring, wstring> ratio = loader.GetCurrencyRatioEquality(usdUnit, eurUnit);
VERIFY_ARE_EQUAL(ref new String(L"1 USD = 0.9205 EUR"), StringReference(ratio.first.c_str()));
VERIFY_ARE_EQUAL(ref new String(L"1 United States Dollar = 0.9205 Europe Euro"), StringReference(ratio.second.c_str()));
VERIFY_ARE_EQUAL(wstring(L"1 USD = 0.9205 EUR"), ratio.first);
VERIFY_ARE_EQUAL(wstring(L"1 United States Dollar = 0.9205 Europe Euro"), ratio.second);
}
TEST_METHOD(Loaded_GetCurrencyRatioEquality_Invalid)
@ -578,8 +578,8 @@ namespace CalculatorUnitTests
pair<wstring, wstring> ratio = loader.GetCurrencyRatioEquality(fakeUnit1, fakeUnit2);
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(ratio.first.c_str()));
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(ratio.second.c_str()));
VERIFY_ARE_EQUAL(wstring(L""), ratio.first);
VERIFY_ARE_EQUAL(wstring(L""), ratio.second);
// Verify that when only one unit is valid, both symbols return as empty string.
vector<UCM::Unit> unitList = loader.LoadOrderedUnits(CURRENCY_CATEGORY);
@ -589,13 +589,13 @@ namespace CalculatorUnitTests
ratio = loader.GetCurrencyRatioEquality(fakeUnit1, usdUnit);
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(ratio.first.c_str()));
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(ratio.second.c_str()));
VERIFY_ARE_EQUAL(wstring(L""), ratio.first);
VERIFY_ARE_EQUAL(wstring(L""), ratio.second);
ratio = loader.GetCurrencyRatioEquality(usdUnit, fakeUnit1);
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(ratio.first.c_str()));
VERIFY_ARE_EQUAL(ref new String(L""), StringReference(ratio.second.c_str()));
VERIFY_ARE_EQUAL(wstring(L""), ratio.first);
VERIFY_ARE_EQUAL(wstring(L""), ratio.second);
}
};
}

View File

@ -42,7 +42,7 @@ namespace CalculatorFunctionalTests
HistoryViewModel^ m_historyViewModel;
StandardCalculatorViewModel^ m_standardViewModel;
void Initialize(unsigned int windowId = 0)
void Initialize()
{
m_standardViewModel = ref new StandardCalculatorViewModel();
m_standardViewModel->IsStandard = true;
@ -50,7 +50,7 @@ namespace CalculatorFunctionalTests
m_historyViewModel->SetCalculatorDisplay(m_standardViewModel->m_calculatorDisplay);
}
void Cleanup(unsigned int windowId = 0)
void Cleanup()
{
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeBasic);
m_historyViewModel->OnClearCommand(nullptr);
@ -79,9 +79,9 @@ namespace CalculatorFunctionalTests
m_standardViewModel->IsFToEEnabled = false;
}
void AddSingleHistoryItem(unsigned int windowId = 0)
void AddSingleHistoryItem()
{
Initialize(windowId);
Initialize();
int initialSize = m_historyViewModel->ItemSize;
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
@ -94,25 +94,24 @@ namespace CalculatorFunctionalTests
VERIFY_ARE_EQUAL(initialSize + 1, sizeAfterItemAdd);
VERIFY_ARE_EQUAL(expression, StringReference(historyItem->historyItemVector.expression.c_str()));
VERIFY_ARE_EQUAL(result, StringReference(historyItem->historyItemVector.result.c_str()));
Cleanup(windowId);
Cleanup();
}
void AddMaxHistoryItems(unsigned int windowId = 0)
void AddMaxHistoryItems()
{
Initialize(windowId);
int initialSize = m_historyViewModel->ItemSize;
Initialize();
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
for (int i = 1; i < m_standardViewModel->m_standardCalculatorManager.MaxHistorySize(); i++)
for (size_t i = 1; i < m_standardViewModel->m_standardCalculatorManager.MaxHistorySize(); i++)
{
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command2);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
}
VERIFY_ARE_EQUAL(m_historyViewModel->ItemSize, m_standardViewModel->m_standardCalculatorManager.MaxHistorySize());
VERIFY_ARE_EQUAL((size_t)m_historyViewModel->ItemSize, m_standardViewModel->m_standardCalculatorManager.MaxHistorySize());
String ^expression = UtfUtils::LRO + L"1 + 1 =" + UtfUtils::PDF;
int output = 2;
String ^result = output.ToString();
@ -123,19 +122,19 @@ namespace CalculatorFunctionalTests
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command5);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandEQU);
VERIFY_ARE_EQUAL(m_historyViewModel->ItemSize, m_standardViewModel->m_standardCalculatorManager.MaxHistorySize());
VERIFY_ARE_EQUAL((size_t)m_historyViewModel->ItemSize, m_standardViewModel->m_standardCalculatorManager.MaxHistorySize());
expression = UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF;
output = 3;
result = output.ToString();
historyItem = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
VERIFY_ARE_EQUAL(expression, StringReference(historyItem->historyItemVector.expression.c_str()));
VERIFY_ARE_EQUAL(result, StringReference(historyItem->historyItemVector.result.c_str()));
Cleanup(windowId);
Cleanup();
}
void ReloadHistory(unsigned int windowId = 0)
void ReloadHistory()
{
Initialize(windowId);
Initialize();
m_standardViewModel->m_standardCalculatorManager.Reset();
int scientificItems = 5;
@ -187,12 +186,12 @@ namespace CalculatorFunctionalTests
VERIFY_ARE_EQUAL(expr, historyItem->historyItemVector.expression);
VERIFY_ARE_EQUAL(result, StringReference(historyItem->historyItemVector.result.c_str()));
}
Cleanup(windowId);
Cleanup();
}
void ClearHistory(unsigned int windowId = 0)
void ClearHistory()
{
Initialize(windowId);
Initialize();
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
@ -207,12 +206,12 @@ namespace CalculatorFunctionalTests
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
VERIFY_IS_TRUE(IsHistoryContainerEmpty(GetHistoryContainerKeyHelper(CM_STD)));
VERIFY_IS_TRUE(IsHistoryContainerEmpty(GetHistoryContainerKeyHelper(CM_SCI)));
Cleanup(windowId);
Cleanup();
}
void SerializeDeSerializeHistoryItem(unsigned int windowId = 0)
void SerializeDeSerializeHistoryItem()
{
Initialize(windowId);
Initialize();
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
@ -223,12 +222,12 @@ namespace CalculatorFunctionalTests
m_historyViewModel->ReloadHistory(ViewMode::Scientific);
auto itemAfterSerializeDeserialize = m_standardViewModel->m_standardCalculatorManager.GetHistoryItem(0);
VERIFY_IS_TRUE((itemBeforeSerializeDeserialize->historyItemVector.expression == itemAfterSerializeDeserialize->historyItemVector.expression) && (itemBeforeSerializeDeserialize->historyItemVector.result == itemAfterSerializeDeserialize->historyItemVector.result) && (itemBeforeSerializeDeserialize->historyItemVector.spCommands == itemAfterSerializeDeserialize->historyItemVector.spCommands) && (itemBeforeSerializeDeserialize->historyItemVector.spTokens == itemAfterSerializeDeserialize->historyItemVector.spTokens));
Cleanup(windowId);
Cleanup();
}
void SaveAndReloadHistory(unsigned int windowid = 0)
void SaveAndReloadHistory()
{
Initialize(windowid);
Initialize();
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
@ -258,12 +257,12 @@ namespace CalculatorFunctionalTests
VERIFY_ARE_EQUAL(result, StringReference(historyItem->historyItemVector.result.c_str()));
VERIFY_ARE_NOT_EQUAL(itemsBeforeSaveAndReload, itemsAfterSaveAndReload);
VERIFY_ARE_EQUAL(itemsBeforeSaveAndReload, itemsAfterSaveAndReload + 1);
Cleanup(windowid);
Cleanup();
}
void HistoryItemWithPrettyExpressions(unsigned int windowId = 0)
void HistoryItemWithPrettyExpressions()
{
Initialize(windowId);
Initialize();
Command commands[] = { Command::CommandSIN, Command::CommandCOS, Command::CommandTAN, Command::CommandASIN, Command::CommandACOS, Command::CommandATAN };
Command mode[] = { Command::CommandDEG, Command::CommandRAD, Command::CommandGRAD };
int modes = sizeof(mode) / sizeof(Command);
@ -290,12 +289,12 @@ namespace CalculatorFunctionalTests
itemIndex++;
}
}
Cleanup(windowId);
Cleanup();
}
void HistoryItemWithPrettyExpressionsMixedRadix(unsigned int windowId = 0)
void HistoryItemWithPrettyExpressionsMixedRadix()
{
Initialize(windowId);
Initialize();
ResourceLoader^ m_uiResourceLoader = ResourceLoader::GetForViewIndependentUse(L"CEngineStrings");
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandDEG);
@ -321,12 +320,12 @@ namespace CalculatorFunctionalTests
expr = UtfUtils::LRO + expr + UtfUtils::PDF;
VERIFY_ARE_EQUAL(historyItem->historyItemVector.expression, expr);
Cleanup(windowId);
Cleanup();
}
void HistoryItemClicked(unsigned int windowId = 0)
void HistoryItemClicked()
{
Initialize(windowId);
Initialize();
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
@ -348,12 +347,12 @@ namespace CalculatorFunctionalTests
VERIFY_ARE_EQUAL(StringReference(L" "), m_standardViewModel->ExpressionTokens->GetAt(5)->Token);
VERIFY_ARE_EQUAL(StringReference(L"+"), m_standardViewModel->ExpressionTokens->GetAt(6)->Token);
VERIFY_ARE_EQUAL(StringReference(L" "), m_standardViewModel->ExpressionTokens->GetAt(7)->Token);
Cleanup(windowId);
Cleanup();
}
void HistoryItemLoadAndContinueCalculation(unsigned int windowId = 0)
void HistoryItemLoadAndContinueCalculation()
{
Initialize(windowId);
Initialize();
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeBasic);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
@ -385,12 +384,12 @@ namespace CalculatorFunctionalTests
item = ref new HistoryItemViewModel(expression, result, historyItem->historyItemVector.spTokens, historyItem->historyItemVector.spCommands);
MockOnHistoryItemClicked(item);
VERIFY_ARE_EQUAL(StringReference(L"14"), m_standardViewModel->DisplayValue);
Cleanup(windowId);
Cleanup();
}
void DisplayValueAutomationNames(unsigned int windowId = 0)
void DisplayValueAutomationNames()
{
Initialize(windowId);
Initialize();
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::CommandADD);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command8);
@ -414,12 +413,12 @@ namespace CalculatorFunctionalTests
expression = StringReference(L"Display is 3");
VERIFY_ARE_EQUAL(expression, m_standardViewModel->CalculationResultAutomationName);
Cleanup(windowId);
Cleanup();
}
void RadixAutomationName(unsigned int windowId = 0)
void RadixAutomationName()
{
Initialize(windowId);
Initialize();
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeProgrammer);
m_standardViewModel->IsProgrammer = true;
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::Command1);
@ -435,26 +434,26 @@ namespace CalculatorFunctionalTests
expression = StringReference(L"Binary 1000");
result = L"Binary " + Utils::GetStringValue(m_standardViewModel->BinaryDisplayValue);
VERIFY_ARE_EQUAL(expression, result);
Cleanup(windowId);
Cleanup();
}
void HistoryEmpty(unsigned int windowId = 0)
void HistoryEmpty()
{
Initialize(windowId);
Initialize();
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
Cleanup(windowId);
Cleanup();
}
void HistoryClearCommandWithEmptyHistory(unsigned int windowId = 0)
void HistoryClearCommandWithEmptyHistory()
{
Initialize(windowId);
Initialize();
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
m_standardViewModel->m_standardCalculatorManager.SendCommand(Command::ModeScientific);
m_historyViewModel->OnClearCommand(nullptr);
VERIFY_ARE_EQUAL(0, m_historyViewModel->ItemSize);
Cleanup(windowId);
Cleanup();
}
};

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"
@ -274,7 +274,7 @@ namespace CalculatorUnitTests
for (size_t index = 0; index < orderedModes.size(); index++)
{
ViewMode mode = orderedModes[index];
VERIFY_ARE_EQUAL(index, NavCategory::GetIndex(mode));
VERIFY_ARE_EQUAL(index, (size_t)NavCategory::GetIndex(mode));
}
VERIFY_ARE_EQUAL(-1, NavCategory::GetIndex(ViewMode::None));
@ -306,7 +306,7 @@ namespace CalculatorUnitTests
for (size_t pos = 1; pos <= orderedModes.size(); pos++)
{
ViewMode mode = orderedModes[pos - 1];
VERIFY_ARE_EQUAL(pos, NavCategory::GetPosition(mode));
VERIFY_ARE_EQUAL(pos, (size_t)NavCategory::GetPosition(mode));
}
VERIFY_ARE_EQUAL(-1, NavCategory::GetPosition(ViewMode::None));

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"
@ -116,7 +116,7 @@ namespace UnitConverterUnitTests
return m_ratioMaps[u];
}
bool SupportsCategory(const Category& target)
bool SupportsCategory(const Category& /*target*/)
{
return true;
}

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"
@ -234,7 +234,7 @@ namespace CalculatorUnitTests
return wstring(L"");
}
void UnitConverterMock::DeSerialize(const wstring& serializedData)
void UnitConverterMock::DeSerialize(const wstring& /*serializedData*/)
{
m_deSerializeCallCount++;
}
@ -244,7 +244,7 @@ namespace CalculatorUnitTests
return L"TEST";
};
void UnitConverterMock::RestoreUserPreferences(_In_ const std::wstring& userPreferences)
void UnitConverterMock::RestoreUserPreferences(_In_ const std::wstring& /*userPreferences*/)
{
};

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"
@ -41,7 +41,7 @@ namespace CalculatorUnitTests
void RestoreUserPreferences(_In_ const std::wstring& userPreferences) override;
void SendCommand(UCM::Command command) override;
void SetViewModelCallback(const std::shared_ptr<UCM::IUnitConverterVMCallback>& newCallback) override;
void SetViewModelCurrencyCallback(_In_ const std::shared_ptr<UCM::IViewModelCurrencyCallback>& newCallback) override {}
void SetViewModelCurrencyCallback(_In_ const std::shared_ptr<UCM::IViewModelCurrencyCallback>& /*newCallback*/) override {}
concurrency::task<std::pair<bool, std::wstring>> RefreshCurrencyRatios() override
{
co_return std::make_pair(L"", L"");