Merge branch 'master' into master

This commit is contained in:
Will 2019-03-10 14:59:27 -04:00 committed by GitHub
commit 8cc44b996e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 312 additions and 247 deletions

View file

@ -2,7 +2,7 @@
The Windows Calculator app is a modern Windows app written in C++ that ships pre-installed with Windows.
The app provides standard, scientific, and programmer calculator functionality, as well as a set of converters between various units of measurement and currencies.
Calculator ships regularly with new features and bug fixes. You can get the latest version of Calculator in the [Microsoft Store.](https://www.microsoft.com/store/apps/9WZDNCRFHVN5)
Calculator ships regularly with new features and bug fixes. You can get the latest version of Calculator in the [Microsoft Store](https://www.microsoft.com/store/apps/9WZDNCRFHVN5).
[![Build Status](https://dev.azure.com/ms/calculator/_apis/build/status/Calculator-CI?branchName=master)](https://dev.azure.com/ms/calculator/_build/latest?definitionId=57&branchName=master)
@ -18,14 +18,14 @@ Calculator ships regularly with new features and bug fixes. You can get the late
## Getting started
Prerequisites:
- Your computer must be running Windows 10, version 1803 or newer
- Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient)
- Install the "Universal Windows Platform Development" workload
- Install the optional "C++ Universal Windows Platform tools" component
- Install the latest Windows 10 SDK
- Your computer must be running Windows 10, version 1803 or newer.
- Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient).
- Install the "Universal Windows Platform Development" workload.
- Install the optional "C++ Universal Windows Platform tools" component.
- Install the latest Windows 10 SDK.
![Visual Studio Installation Screenshot](docs/Images/VSInstallationScreenshot.png)
- Install the [XAML Styler](https://marketplace.visualstudio.com/items?itemName=TeamXavalon.XAMLStyler) Visual Studio extension
- Install the [XAML Styler](https://marketplace.visualstudio.com/items?itemName=TeamXavalon.XAMLStyler) Visual Studio extension.
- Get the code:
```

View file

@ -11,9 +11,6 @@ namespace Calculator.UIAutomationLibrary.Components
/// <summary>
/// Physical Object Model for the app window.
/// POM is the implementation model of the app.
/// See following references to POM:
/// * https://blogs.msdn.microsoft.com/wltester/2011/11/14/object-model-design/
/// * https://blogs.msdn.microsoft.com/micahel/2005/06/03/how-do-i-invoke-thee-let-me-count-the-ways-the-physical-object-model/
/// See https://en.wikipedia.org/wiki/Model-based_testing for model-based testing.
/// </summary>
public class MainPagePom : UIObject

10
src/.editorconfig Normal file
View file

@ -0,0 +1,10 @@
root = true
[*.{xaml,cpp,h}]
charset = utf-8-bom
indent_style = space
indent_size = 4
[*.{cpp,h}]
insert_final_newline = true
trim_trailing_whitespace = true

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{};
@ -303,4 +303,3 @@ void COpndCommand::Accept(_In_ ISerializeCommandVisitor &commandVisitor)
{
commandVisitor.Visit(*this);
}

View file

@ -6,47 +6,47 @@
#include "Header Files/CalcEngine.h"
#include "Header Files/Rational.h"
class CParentheses : public IParenthesisCommand
class CParentheses final : public IParenthesisCommand
{
public:
CParentheses(_In_ int command);
int GetCommand() const;
CalculationManager::CommandType GetCommandType() const;
void Accept(_In_ ISerializeCommandVisitor &commandVisitor);
int GetCommand() const override;
CalculationManager::CommandType GetCommandType() const override;
void Accept(_In_ ISerializeCommandVisitor &commandVisitor) override;
private:
int m_command;
};
class CUnaryCommand : public IUnaryCommand
class CUnaryCommand final : public IUnaryCommand
{
public:
CUnaryCommand(int command);
CUnaryCommand(int command1, int command2);
const std::shared_ptr<CalculatorVector<int>> & GetCommands() const;
CalculationManager::CommandType GetCommandType() const;
void SetCommand(int command);
void SetCommands(int command1, int command2);
void Accept(_In_ ISerializeCommandVisitor &commandVisitor);
const std::shared_ptr<CalculatorVector<int>> & GetCommands() const override;
CalculationManager::CommandType GetCommandType() const override;
void SetCommand(int command) override;
void SetCommands(int command1, int command2) override;
void Accept(_In_ ISerializeCommandVisitor &commandVisitor) override;
private:
std::shared_ptr<CalculatorVector<int>> m_command;
};
class CBinaryCommand : public IBinaryCommand
class CBinaryCommand final : public IBinaryCommand
{
public:
CBinaryCommand(int command);
void SetCommand(int command);
int GetCommand() const;
CalculationManager::CommandType GetCommandType() const;
void Accept(_In_ ISerializeCommandVisitor &commandVisitor);
void SetCommand(int command) override;
int GetCommand() const override;
CalculationManager::CommandType GetCommandType() const override;
void Accept(_In_ ISerializeCommandVisitor &commandVisitor) override;
private:
int m_command;
};
class COpndCommand : public IOpndCommand
class COpndCommand final : public IOpndCommand
{
public:
COpndCommand(
@ -56,18 +56,18 @@ public:
bool fSciFmt);
void Initialize(CalcEngine::Rational const& rat);
const std::shared_ptr<CalculatorVector<int>> & GetCommands() const;
void SetCommands(std::shared_ptr<CalculatorVector<int>> const& commands);
void AppendCommand(int command);
void ToggleSign();
void RemoveFromEnd();
bool IsNegative() const;
bool IsSciFmt() const;
bool IsDecimalPresent() const;
const std::wstring & GetToken(wchar_t decimalSymbol);
CalculationManager::CommandType GetCommandType() const;
void Accept(_In_ ISerializeCommandVisitor &commandVisitor);
std::wstring GetString(uint32_t radix, int32_t precision, wchar_t decimalSymbol);
const std::shared_ptr<CalculatorVector<int>> & GetCommands() const override;
void SetCommands(std::shared_ptr<CalculatorVector<int>> const& commands) override;
void AppendCommand(int command) override;
void ToggleSign() override;
void RemoveFromEnd() override;
bool IsNegative() const override;
bool IsSciFmt() const override;
bool IsDecimalPresent() const override;
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);
private:
std::shared_ptr<CalculatorVector<int>> m_commands;

View file

@ -30,7 +30,7 @@ public:
class IBinaryCommand : public IOperatorCommand
{
public:
virtual void SetCommand(int command) = 0;
virtual void SetCommand(int command) override = 0;
virtual int GetCommand() const = 0;
};

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

@ -302,8 +302,8 @@ wstring UnitConverter::Serialize()
out << std::to_wstring(m_currentHasDecimal) << delimiter << std::to_wstring(m_returnHasDecimal) << delimiter << std::to_wstring(m_switchedActive) << delimiter;
out << m_currentDisplay << delimiter << m_returnDisplay << delimiter << "|";
wstringstream categoryString(wstringstream::out);
wstringstream categoryToUnitString(wstringstream::out);;
wstringstream unitToUnitToDoubleString(wstringstream::out);;
wstringstream categoryToUnitString(wstringstream::out);
wstringstream unitToUnitToDoubleString(wstringstream::out);
for (const Category& c : m_categories)
{
categoryString << CategoryToString(c, delimiter) << ",";

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;
@ -89,6 +88,14 @@ namespace CalculatorApp
auto timer = ref new DispatcherTimer();
timer->Interval = c_lightUpTime;
// 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();
TimeSpan lightUpTime{};
lightUpTime.Duration = 500000L; // Half second (in 100-ns units)
timer->Interval = lightUpTime;
WeakReference timerWeakReference(timer);
WeakReference buttonWeakReference(button);
timer->Tick += ref new EventHandler<Object^>(
@ -579,9 +586,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 +600,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 +643,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 +656,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

@ -26,8 +26,9 @@ namespace CalculatorApp
m_digitSymbols.at(i) = formatter->FormatUInt(i)->Data()[0];
}
wchar_t resolvedName[LOCALE_NAME_MAX_LENGTH];
result = ResolveLocaleName(formatter->ResolvedLanguage->Data(),
m_resolvedName,
resolvedName,
LOCALE_NAME_MAX_LENGTH);
if (result == 0)
{
@ -35,8 +36,9 @@ namespace CalculatorApp
}
else
{
m_resolvedName = resolvedName;
wchar_t decimalString[LocaleSettingBufferSize] = L"";
result = GetLocaleInfoEx(m_resolvedName,
result = GetLocaleInfoEx(m_resolvedName.c_str(),
LOCALE_SDECIMAL,
decimalString,
ARRAYSIZE(decimalString));
@ -46,7 +48,7 @@ namespace CalculatorApp
}
wchar_t groupingSymbolString[LocaleSettingBufferSize] = L"";
result = GetLocaleInfoEx(m_resolvedName,
result = GetLocaleInfoEx(m_resolvedName.c_str(),
LOCALE_STHOUSAND,
groupingSymbolString,
ARRAYSIZE(groupingSymbolString));
@ -56,7 +58,7 @@ namespace CalculatorApp
}
wchar_t numberGroupingString[LocaleSettingBufferSize] = L"";
result = GetLocaleInfoEx(m_resolvedName,
result = GetLocaleInfoEx(m_resolvedName.c_str(),
LOCALE_SGROUPING,
numberGroupingString,
ARRAYSIZE(numberGroupingString));
@ -77,7 +79,7 @@ namespace CalculatorApp
}
int currencyTrailingDigits = 0;
result = GetLocaleInfoEx(m_resolvedName,
result = GetLocaleInfoEx(m_resolvedName.c_str(),
LOCALE_ICURRDIGITS | LOCALE_RETURN_NUMBER,
(LPWSTR)&currencyTrailingDigits,
sizeof(currencyTrailingDigits) / sizeof(WCHAR));
@ -147,7 +149,7 @@ namespace CalculatorApp
Platform::String^ GetLocaleName() const
{
return ref new Platform::String(m_resolvedName);
return ref new Platform::String(m_resolvedName.c_str());
}
bool IsDigitEnUsSetting() const
@ -377,7 +379,7 @@ namespace CalculatorApp
Platform::String^ m_calendarIdentifier;
Windows::Globalization::DayOfWeek m_firstDayOfWeek;
int m_currencySymbolPrecedence;
wchar_t m_resolvedName[LOCALE_NAME_MAX_LENGTH];
std::wstring m_resolvedName;
int m_currencyTrailingDigits;
static const unsigned int LocaleSettingBufferSize = 16;
};

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

@ -275,7 +275,7 @@ pair<wstring, wstring> CurrencyDataLoader::GetCurrencyRatioEquality(_In_ const U
{
double ratio = (iter2->second).ratio;
// Round the raio to FORMATTER_DIGIT_COUNT digits using int math.
// Round the ratio to FORMATTER_DIGIT_COUNT digits using int math.
// Ex: to round 1.23456 to three digits, use
// ((int) 1.23456 * (10^3)) / (10^3)
double scale = pow(10, FORMATTER_DIGIT_COUNT);

View file

@ -158,7 +158,6 @@ void UnitConverterDataLoader::GetUnits(_In_ unordered_map<ViewMode, vector<Order
{
// US + Federated States of Micronesia, Marshall Islands, Palau
bool useUSCustomaryAndFahrenheit = m_currentRegionCode == L"US" ||
m_currentRegionCode == L"PW" ||
m_currentRegionCode == L"FM" ||
m_currentRegionCode == L"MH" ||
m_currentRegionCode == L"PW";

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,9 +485,9 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
{
// Clear older text;
m_selectedExpressionLastData = L"";
if (ch == 'x')
if (ch == L'x')
{
temp = L'\0';
temp[0] = L'\0';
commandIndex = 0;
}
else
@ -501,11 +500,11 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
}
else
{
if (ch == 'x')
if (ch == L'x')
{
if (commandIndex == 0)
{
delete temp;
delete [] temp;
return;
}
@ -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;
}
}
@ -553,7 +552,7 @@ bool StandardCalculatorViewModel::IsOperator(Command cmdenum)
{
if ((cmdenum == Command::Command0) || (cmdenum == Command::Command1) || (cmdenum == Command::Command2) || (cmdenum == Command::Command3) || (cmdenum == Command::Command4) || (cmdenum == Command::Command5)
|| (cmdenum == Command::Command6) || (cmdenum == Command::Command7) || (cmdenum == Command::Command8) || (cmdenum == Command::Command9) || (cmdenum == Command::CommandPNT) || (cmdenum == Command::CommandBACK)
|| (cmdenum == Command::CommandEXP) || (cmdenum == Command::CommandFE) || (cmdenum == Command::ModeBasic) || (cmdenum == Command::ModeBasic) || (cmdenum == Command::ModeProgrammer) || (cmdenum == Command::ModeScientific)
|| (cmdenum == Command::CommandEXP) || (cmdenum == Command::CommandFE) || (cmdenum == Command::ModeBasic) || (cmdenum == Command::ModeProgrammer) || (cmdenum == Command::ModeScientific)
|| (cmdenum == Command::CommandINV) || (cmdenum == Command::CommandCENTR) || (cmdenum == Command::CommandDEG) || (cmdenum == Command::CommandRAD) || (cmdenum == Command::CommandGRAD)
|| ((cmdenum >= Command::CommandBINEDITSTART) && (cmdenum <= Command::CommandBINEDITEND)))
{
@ -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

@ -9,6 +9,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalcManager", "CalcManager\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A5DF651-B8A1-45CA-9135-964A6FC7F5D1}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
nuget.config = nuget.config
EndProjectSection
EndProject

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

@ -30,7 +30,6 @@ CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel() :
{
InitializeComponent();
auto booleanToVisibilityConverter = ref new Converters::BooleanToVisibilityConverter;
auto booleanToVisibilityNegationConverter = ref new Converters::BooleanToVisibilityNegationConverter;
SetVisibilityBinding(BitFlipPanel, L"IsBinaryBitFlippingEnabled", booleanToVisibilityConverter);
AssignFlipButtons();

View file

@ -46,7 +46,7 @@ DateCalculator::DateCalculator()
// Set Calendar Identifier
DateDiff_FromDate->CalendarIdentifier = localizationSettings.GetCalendarIdentifier();
DateDiff_ToDate->CalendarIdentifier = localizationSettings.GetCalendarIdentifier();;
DateDiff_ToDate->CalendarIdentifier = localizationSettings.GetCalendarIdentifier();
// Setting the FirstDayofWeek
DateDiff_FromDate->FirstDayOfWeek = localizationSettings.GetFirstDayOfWeek();

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"
@ -34,7 +34,7 @@ namespace CalculatorUnitTests
#define ASSERT_NEGATIVE_TESTCASES(func, dataSet) \
{\
int size = sizeof(dataSet)/sizeof(*dataSet);;\
int size = sizeof(dataSet)/sizeof(*dataSet);\
while(--size)\
{\
VERIFY_ARE_EQUAL(func(dataSet[size]), StringReference(L"NoOp"));\

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"");