Secondary formatting changes (#489)
Description of the changes: Adjusted some of the values in .clang-format Add clang-format-all.ps1 Fix path to .clang-format in Calculator.sln How changes were validated: Manual.
This commit is contained in:
@@ -22,8 +22,8 @@ namespace CalculatorEngineTests
|
||||
m_resourceProvider = make_shared<EngineResourceProvider>();
|
||||
m_history = make_shared<CalculatorHistory>(MAX_HISTORY_SIZE);
|
||||
CCalcEngine::InitialOneTimeOnlySetup(*(m_resourceProvider.get()));
|
||||
m_calcEngine = make_unique<CCalcEngine>(false /* Respect Order of Operations */, false /* Set to Integer Mode */, m_resourceProvider.get(), nullptr,
|
||||
m_history);
|
||||
m_calcEngine = make_unique<CCalcEngine>(
|
||||
false /* Respect Order of Operations */, false /* Set to Integer Mode */, m_resourceProvider.get(), nullptr, m_history);
|
||||
}
|
||||
TEST_METHOD_CLEANUP(Cleanup)
|
||||
{
|
||||
@@ -52,8 +52,8 @@ namespace CalculatorEngineTests
|
||||
VERIFY_ARE_EQUAL(L"1,234,567,890", m_calcEngine->GroupDigitsPerRadix(L"1234567890", 10), L"Verify grouping in base10.");
|
||||
VERIFY_ARE_EQUAL(L"1,234,567.89", m_calcEngine->GroupDigitsPerRadix(L"1234567.89", 10), L"Verify grouping in base10 with decimal.");
|
||||
VERIFY_ARE_EQUAL(L"1,234,567e89", m_calcEngine->GroupDigitsPerRadix(L"1234567e89", 10), L"Verify grouping in base10 with exponent.");
|
||||
VERIFY_ARE_EQUAL(L"1,234,567.89e5", m_calcEngine->GroupDigitsPerRadix(L"1234567.89e5", 10),
|
||||
L"Verify grouping in base10 with decimal and exponent.");
|
||||
VERIFY_ARE_EQUAL(
|
||||
L"1,234,567.89e5", m_calcEngine->GroupDigitsPerRadix(L"1234567.89e5", 10), L"Verify grouping in base10 with decimal and exponent.");
|
||||
VERIFY_ARE_EQUAL(L"-123,456,789", m_calcEngine->GroupDigitsPerRadix(L"-123456789", 10), L"Verify grouping in base10 with negative.");
|
||||
}
|
||||
|
||||
@@ -118,18 +118,29 @@ namespace CalculatorEngineTests
|
||||
// Regex matching (descriptions taken from CalcUtils.cpp)
|
||||
// Use 100 for exp/mantissa length as they are tested above
|
||||
vector<wstring> validDecStrs{ // Start with an optional + or -
|
||||
L"+1", L"-1", L"1",
|
||||
L"+1",
|
||||
L"-1",
|
||||
L"1",
|
||||
// Followed by zero or more digits
|
||||
L"-", L"", L"1234567890",
|
||||
L"-",
|
||||
L"",
|
||||
L"1234567890",
|
||||
// Followed by an optional decimal point
|
||||
L"1.0", L"-.", L"1.",
|
||||
L"1.0",
|
||||
L"-.",
|
||||
L"1.",
|
||||
// Followed by zero or more digits
|
||||
L"0.0", L"0.123456",
|
||||
L"0.0",
|
||||
L"0.123456",
|
||||
// Followed by an optional exponent ('e')
|
||||
L"1e", L"1.e", L"-e",
|
||||
L"1e",
|
||||
L"1.e",
|
||||
L"-e",
|
||||
// If there's an exponent, its optionally followed by + or -
|
||||
// and followed by zero or more digits
|
||||
L"1e+12345", L"1e-12345", L"1e123",
|
||||
L"1e+12345",
|
||||
L"1e-12345",
|
||||
L"1e123",
|
||||
// All together
|
||||
L"-123.456e+789"
|
||||
};
|
||||
@@ -204,16 +215,18 @@ namespace CalculatorEngineTests
|
||||
VERIFY_ARE_EQUAL(result, m_calcEngine->GroupDigits(L",", { 3, 0, 0 }, L"1234567890123456", false), L"Verify expanded form non-repeating grouping.");
|
||||
|
||||
result = L"12,34,56,78,901,23456";
|
||||
VERIFY_ARE_EQUAL(result, m_calcEngine->GroupDigits(L",", { 5, 3, 2, 0 }, L"1234567890123456", false),
|
||||
L"Verify multigroup with repeating grouping.");
|
||||
VERIFY_ARE_EQUAL(
|
||||
result, m_calcEngine->GroupDigits(L",", { 5, 3, 2, 0 }, L"1234567890123456", false), L"Verify multigroup with repeating grouping.");
|
||||
|
||||
result = L"1234,5678,9012,3456";
|
||||
VERIFY_ARE_EQUAL(result, m_calcEngine->GroupDigits(L",", { 4, 0 }, L"1234567890123456", false), L"Verify repeating non-standard grouping.");
|
||||
|
||||
result = L"123456,78,901,23456";
|
||||
VERIFY_ARE_EQUAL(result, m_calcEngine->GroupDigits(L",", { 5, 3, 2 }, L"1234567890123456", false), L"Verify multigroup non-repeating grouping.");
|
||||
VERIFY_ARE_EQUAL(result, m_calcEngine->GroupDigits(L",", { 5, 3, 2, 0, 0 }, L"1234567890123456", false),
|
||||
L"Verify expanded form multigroup non-repeating grouping.");
|
||||
VERIFY_ARE_EQUAL(
|
||||
result,
|
||||
m_calcEngine->GroupDigits(L",", { 5, 3, 2, 0, 0 }, L"1234567890123456", false),
|
||||
L"Verify expanded form multigroup non-repeating grouping.");
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -173,8 +173,8 @@ namespace CalculatorEngineTests
|
||||
m_calcInput.Backspace();
|
||||
m_calcInput.TryToggleSign(true, L"127");
|
||||
VERIFY_IS_FALSE(m_calcInput.TryAddDigit(9, 10, true, L"127", 8, 2), L"Negative value: verify we cannot add a digit if digit exceeds max value.");
|
||||
VERIFY_IS_TRUE(m_calcInput.TryAddDigit(8, 10, true, L"127", 8, 2),
|
||||
L"Negative value: verify we can add a digit if digit does not exceed max value.");
|
||||
VERIFY_IS_TRUE(
|
||||
m_calcInput.TryAddDigit(8, 10, true, L"127", 8, 2), L"Negative value: verify we can add a digit if digit does not exceed max value.");
|
||||
}
|
||||
|
||||
TEST_METHOD(TryAddDecimalPtEmpty)
|
||||
|
@@ -40,8 +40,9 @@ 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;
|
||||
|
@@ -60,20 +60,28 @@ namespace CalculatorUnitTests
|
||||
}
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.ValidatePasteExpression(StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1),
|
||||
StringReference(exp_TooLong.c_str()), L"Verify ValidatePasteExpression handles expressions up to max length");
|
||||
StringReference(exp_TooLong.c_str()),
|
||||
L"Verify ValidatePasteExpression handles expressions up to max length");
|
||||
exp_TooLong += L"1";
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.ValidatePasteExpression(StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1),
|
||||
StringReference(L"NoOp"), L"Verify ValidatePasteExpression returns NoOp for strings over max length");
|
||||
StringReference(L"NoOp"),
|
||||
L"Verify ValidatePasteExpression returns NoOp for strings over max length");
|
||||
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.ValidatePasteExpression(StringReference(L""), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1),
|
||||
StringReference(L"NoOp"), L"Verify empty string is invalid");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.ValidatePasteExpression(StringReference(L""), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1),
|
||||
StringReference(L"NoOp"),
|
||||
L"Verify empty string is invalid");
|
||||
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123e456"), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1),
|
||||
StringReference(L"NoOp"), L"Verify pasting unsupported strings for the current mode is invalid");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123e456"), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1),
|
||||
StringReference(L"NoOp"),
|
||||
L"Verify pasting unsupported strings for the current mode is invalid");
|
||||
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123"), ViewMode::None, CategoryGroupType::None, -1, -1),
|
||||
StringReference(L"NoOp"), L"Verify pasting without a ViewMode or Category is invalid");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123"), ViewMode::None, CategoryGroupType::None, -1, -1),
|
||||
StringReference(L"NoOp"),
|
||||
L"Verify pasting without a ViewMode or Category is invalid");
|
||||
};
|
||||
|
||||
TEST_METHOD(ValidateExtractOperands)
|
||||
@@ -107,54 +115,70 @@ namespace CalculatorUnitTests
|
||||
{
|
||||
exp_OperandLimit += L"+1";
|
||||
}
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.ExtractOperands(exp_OperandLimit, ViewMode::Standard).size(), 100,
|
||||
L"Verify ExtractOperands handles up to MaxOperandCount operands");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.ExtractOperands(exp_OperandLimit, ViewMode::Standard).size(),
|
||||
100,
|
||||
L"Verify ExtractOperands handles up to MaxOperandCount operands");
|
||||
|
||||
exp_OperandLimit += L"+1";
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.ExtractOperands(exp_OperandLimit, ViewMode::Standard).size(), 0,
|
||||
L"Verify ExtractOperands returns empty vector on too many operands");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.ExtractOperands(exp_OperandLimit, ViewMode::Standard).size(),
|
||||
0,
|
||||
L"Verify ExtractOperands returns empty vector on too many operands");
|
||||
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.ExtractOperands(L"12e9999", ViewMode::Standard).size(), 1,
|
||||
L"Verify ExtractOperands handles up to 4 digit exponents");
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.ExtractOperands(L"12e10000", ViewMode::Standard).size(), 0,
|
||||
L"Verify ExtractOperands returns empty vector when the exponent is too long");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.ExtractOperands(L"12e9999", ViewMode::Standard).size(), 1, L"Verify ExtractOperands handles up to 4 digit exponents");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.ExtractOperands(L"12e10000", ViewMode::Standard).size(),
|
||||
0,
|
||||
L"Verify ExtractOperands returns empty vector when the exponent is too long");
|
||||
};
|
||||
|
||||
TEST_METHOD(ValidateExpressionRegExMatch)
|
||||
{
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{}, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1),
|
||||
L"Verify empty list of operands returns false.");
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123" }, ViewMode::None, CategoryGroupType::Calculator, -1, -1),
|
||||
L"Verify invalid ViewMode/CategoryGroups return false.");
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123" }, ViewMode::Currency, CategoryGroupType::None, -1, -1),
|
||||
L"Verify invalid ViewMode/CategoryGroups return false.");
|
||||
VERIFY_IS_FALSE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{}, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1),
|
||||
L"Verify empty list of operands returns false.");
|
||||
VERIFY_IS_FALSE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123" }, ViewMode::None, CategoryGroupType::Calculator, -1, -1),
|
||||
L"Verify invalid ViewMode/CategoryGroups return false.");
|
||||
VERIFY_IS_FALSE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123" }, ViewMode::Currency, CategoryGroupType::None, -1, -1),
|
||||
L"Verify invalid ViewMode/CategoryGroups return false.");
|
||||
|
||||
Logger::WriteMessage(L"Verify operand lengths > max return false.");
|
||||
VERIFY_IS_FALSE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"12345678901234567" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123456789012345678901234567890123" }, ViewMode::Scientific,
|
||||
CategoryGroupType::Calculator, -1, -1));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"123456789012345678901234567890123" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1));
|
||||
VERIFY_IS_FALSE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"12345678901234567" }, ViewMode::None, CategoryGroupType::Converter, -1, -1));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"11111111111111111" }, ViewMode::Programmer,
|
||||
CategoryGroupType::Calculator, HexBase, QwordType));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"12345678901234567890" }, ViewMode::Programmer,
|
||||
CategoryGroupType::Calculator, DecBase, QwordType));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"11111111111111111111111" }, ViewMode::Programmer,
|
||||
CategoryGroupType::Calculator, OctBase, QwordType));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"10000000000000000000000000000000000000000000000000000000000000000" },
|
||||
ViewMode::Programmer, CategoryGroupType::Calculator, BinBase, QwordType));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"11111111111111111" }, ViewMode::Programmer, CategoryGroupType::Calculator, HexBase, QwordType));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"12345678901234567890" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, QwordType));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"11111111111111111111111" }, ViewMode::Programmer, CategoryGroupType::Calculator, OctBase, QwordType));
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"10000000000000000000000000000000000000000000000000000000000000000" },
|
||||
ViewMode::Programmer,
|
||||
CategoryGroupType::Calculator,
|
||||
BinBase,
|
||||
QwordType));
|
||||
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"9223372036854775808" }, ViewMode::Programmer,
|
||||
CategoryGroupType::Calculator, DecBase, QwordType),
|
||||
L"Verify operand values > max return false.");
|
||||
VERIFY_IS_FALSE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"9223372036854775808" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, QwordType),
|
||||
L"Verify operand values > max return false.");
|
||||
|
||||
VERIFY_IS_TRUE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"((((((((((((((((((((123))))))))))))))))))))" }, ViewMode::Scientific,
|
||||
CategoryGroupType::Calculator, -1, -1),
|
||||
L"Verify sanitized operand is detected as within max length.");
|
||||
VERIFY_IS_TRUE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"9223372036854775807" }, ViewMode::Programmer,
|
||||
CategoryGroupType::Calculator, DecBase, QwordType),
|
||||
L"Verify operand values == max return true.");
|
||||
VERIFY_IS_TRUE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"((((((((((((((((((((123))))))))))))))))))))" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1),
|
||||
L"Verify sanitized operand is detected as within max length.");
|
||||
VERIFY_IS_TRUE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"9223372036854775807" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, QwordType),
|
||||
L"Verify operand values == max return true.");
|
||||
|
||||
Logger::WriteMessage(L"Verify all operands must match patterns.");
|
||||
VERIFY_IS_TRUE(
|
||||
@@ -166,12 +190,14 @@ namespace CalculatorUnitTests
|
||||
m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"1.23e+456" }, ViewMode::Scientific, CategoryGroupType::Calculator, -1, -1),
|
||||
L"Verify operand only needs to match one pattern.");
|
||||
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123", L"12345678901234567" }, ViewMode::Standard,
|
||||
CategoryGroupType::Calculator, -1, -1),
|
||||
L"Verify all operands must be within maxlength");
|
||||
VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch(vector<wstring>{ L"123", L"9223372036854775808" }, ViewMode::Programmer,
|
||||
CategoryGroupType::Calculator, DecBase, QwordType),
|
||||
L"Verify all operand must be within max value.");
|
||||
VERIFY_IS_FALSE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"123", L"12345678901234567" }, ViewMode::Standard, CategoryGroupType::Calculator, -1, -1),
|
||||
L"Verify all operands must be within maxlength");
|
||||
VERIFY_IS_FALSE(
|
||||
m_CopyPasteManager.ExpressionRegExMatch(
|
||||
vector<wstring>{ L"123", L"9223372036854775808" }, ViewMode::Programmer, CategoryGroupType::Calculator, DecBase, QwordType),
|
||||
L"Verify all operand must be within max value.");
|
||||
};
|
||||
|
||||
TEST_METHOD(ValidateGetMaxOperandLengthAndValue)
|
||||
@@ -179,56 +205,78 @@ namespace CalculatorUnitTests
|
||||
pair<size_t, unsigned long long int> standardModeMaximums = make_pair(m_CopyPasteManager.MaxStandardOperandLength, 0);
|
||||
pair<size_t, unsigned long long int> scientificModeMaximums = make_pair(m_CopyPasteManager.MaxScientificOperandLength, 0);
|
||||
pair<size_t, unsigned long long int> converterModeMaximums = make_pair(m_CopyPasteManager.MaxConverterInputLength, 0);
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Standard, CategoryGroupType::None, -1, -1), standardModeMaximums,
|
||||
L"Verify Standard mode maximum values");
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Scientific, CategoryGroupType::None, -1, -1), scientificModeMaximums,
|
||||
L"Verify Scientific mode maximum values");
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::None, CategoryGroupType::Converter, -1, -1), converterModeMaximums,
|
||||
L"Verify Converter mode maximum values");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Standard, CategoryGroupType::None, -1, -1),
|
||||
standardModeMaximums,
|
||||
L"Verify Standard mode maximum values");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Scientific, CategoryGroupType::None, -1, -1),
|
||||
scientificModeMaximums,
|
||||
L"Verify Scientific mode maximum values");
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::None, CategoryGroupType::Converter, -1, -1),
|
||||
converterModeMaximums,
|
||||
L"Verify Converter mode maximum values");
|
||||
|
||||
unsigned long long int ullQwordMax = UINT64_MAX;
|
||||
unsigned long long int ullDwordMax = UINT32_MAX;
|
||||
unsigned long long int ullWordMax = UINT16_MAX;
|
||||
unsigned long long int ullByteMax = UINT8_MAX;
|
||||
Logger::WriteMessage(L"Verify Programmer Mode HexBase maximum values");
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, QwordType),
|
||||
make_pair((size_t)16u, ullQwordMax));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, DwordType),
|
||||
make_pair((size_t)8u, ullDwordMax));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, WordType),
|
||||
make_pair((size_t)4u, ullWordMax));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, ByteType),
|
||||
make_pair((size_t)2u, ullByteMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, QwordType),
|
||||
make_pair((size_t)16u, ullQwordMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, DwordType),
|
||||
make_pair((size_t)8u, ullDwordMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, WordType),
|
||||
make_pair((size_t)4u, ullWordMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, HexBase, ByteType),
|
||||
make_pair((size_t)2u, ullByteMax));
|
||||
|
||||
Logger::WriteMessage(L"Verify Programmer Mode DecBase maximum values");
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, QwordType),
|
||||
make_pair((size_t)19u, ullQwordMax >> 1));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, DwordType),
|
||||
make_pair((size_t)10u, ullDwordMax >> 1));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, WordType),
|
||||
make_pair((size_t)5u, ullWordMax >> 1));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, ByteType),
|
||||
make_pair((size_t)3u, ullByteMax >> 1));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, QwordType),
|
||||
make_pair((size_t)19u, ullQwordMax >> 1));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, DwordType),
|
||||
make_pair((size_t)10u, ullDwordMax >> 1));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, WordType),
|
||||
make_pair((size_t)5u, ullWordMax >> 1));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, DecBase, ByteType),
|
||||
make_pair((size_t)3u, ullByteMax >> 1));
|
||||
|
||||
Logger::WriteMessage(L"Verify Programmer Mode OctBase maximum values");
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, QwordType),
|
||||
make_pair((size_t)22u, ullQwordMax));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, DwordType),
|
||||
make_pair((size_t)11u, ullDwordMax));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, WordType),
|
||||
make_pair((size_t)6u, ullWordMax));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, ByteType),
|
||||
make_pair((size_t)3u, ullByteMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, QwordType),
|
||||
make_pair((size_t)22u, ullQwordMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, DwordType),
|
||||
make_pair((size_t)11u, ullDwordMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, WordType),
|
||||
make_pair((size_t)6u, ullWordMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, OctBase, ByteType),
|
||||
make_pair((size_t)3u, ullByteMax));
|
||||
|
||||
Logger::WriteMessage(L"Verify Programmer Mode BinBase maximum values");
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, QwordType),
|
||||
make_pair((size_t)64u, ullQwordMax));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, DwordType),
|
||||
make_pair((size_t)32u, ullDwordMax));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, WordType),
|
||||
make_pair((size_t)16u, ullWordMax));
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, ByteType),
|
||||
make_pair((size_t)8u, ullByteMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, QwordType),
|
||||
make_pair((size_t)64u, ullQwordMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, DwordType),
|
||||
make_pair((size_t)32u, ullDwordMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, WordType),
|
||||
make_pair((size_t)16u, ullWordMax));
|
||||
VERIFY_ARE_EQUAL(
|
||||
m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Programmer, CategoryGroupType::None, BinBase, ByteType),
|
||||
make_pair((size_t)8u, ullByteMax));
|
||||
|
||||
Logger::WriteMessage(L"Verify invalid ViewModes/Categories return 0 for max values");
|
||||
VERIFY_ARE_EQUAL(m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::None, CategoryGroupType::None, -1, -1), make_pair((size_t)0u, 0ull));
|
||||
|
@@ -29,7 +29,8 @@ namespace CalculatorApp
|
||||
{
|
||||
public:
|
||||
MockCurrencyHttpClientWithResult(String ^ staticResponse, String ^ allRatiosResponse)
|
||||
: m_staticResponse(staticResponse), m_allRatiosResponse(allRatiosResponse)
|
||||
: m_staticResponse(staticResponse)
|
||||
, m_allRatiosResponse(allRatiosResponse)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -71,7 +72,8 @@ namespace CalculatorApp
|
||||
class DataLoadedCallback : public UnitConversionManager::IViewModelCurrencyCallback
|
||||
{
|
||||
public:
|
||||
DataLoadedCallback(task_completion_event<void> tce) : m_task_completion_event{ tce }
|
||||
DataLoadedCallback(task_completion_event<void> tce)
|
||||
: m_task_completion_event{ tce }
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -343,8 +343,8 @@ TEST_METHOD(TestSubtractOob)
|
||||
DateTime endDate;
|
||||
|
||||
// Subtract Duration
|
||||
bool isValid = m_DateCalcEngine.SubtractDuration(DateUtils::SystemTimeToDateTime(datetimeBoundSubtract[testIndex].startDate),
|
||||
datetimeBoundSubtract[testIndex].dateDiff, &endDate);
|
||||
bool isValid = m_DateCalcEngine.SubtractDuration(
|
||||
DateUtils::SystemTimeToDateTime(datetimeBoundSubtract[testIndex].startDate), datetimeBoundSubtract[testIndex].dateDiff, &endDate);
|
||||
|
||||
// Assert for the result
|
||||
VERIFY_IS_FALSE(isValid);
|
||||
|
@@ -40,8 +40,10 @@ namespace DateCalculationUnitTests
|
||||
// Returns long date format for a date
|
||||
static Platform::String ^ GetLongDate(SYSTEMTIME systemTime) {
|
||||
auto formatter = ref new Windows::Globalization::DateTimeFormatting::DateTimeFormatter(
|
||||
L"longdate", Windows::Globalization::ApplicationLanguages::Languages,
|
||||
Windows::System::UserProfile::GlobalizationPreferences::HomeGeographicRegion, Windows::Globalization::CalendarIdentifiers::Gregorian,
|
||||
L"longdate",
|
||||
Windows::Globalization::ApplicationLanguages::Languages,
|
||||
Windows::System::UserProfile::GlobalizationPreferences::HomeGeographicRegion,
|
||||
Windows::Globalization::CalendarIdentifiers::Gregorian,
|
||||
Windows::Globalization::ClockIdentifiers::TwentyFourHour);
|
||||
|
||||
Windows::Foundation::DateTime dateTime = SystemTimeToDateTime(systemTime);
|
||||
|
@@ -221,10 +221,11 @@ namespace CalculatorFunctionalTests
|
||||
m_historyViewModel->SaveHistory();
|
||||
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));
|
||||
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();
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,8 @@ IAsyncOperationWithProgress<String ^, HttpProgress> ^ CurrencyHttpClient::GetCur
|
||||
return ref new MockAsyncOperationWithProgress(StringReference(ALL_RATIOS_RESPONSE));
|
||||
}
|
||||
|
||||
MockAsyncOperationWithProgress::MockAsyncOperationWithProgress(String ^ result) : m_result(result)
|
||||
MockAsyncOperationWithProgress::MockAsyncOperationWithProgress(String ^ result)
|
||||
: m_result(result)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -270,7 +270,8 @@ namespace CalculatorUnitTests
|
||||
{ NumbersAndOperatorsEnum::Five, L"7" + std::wstring(m_decimalSeparator->Data()) + L"5", L"" },
|
||||
{ NumbersAndOperatorsEnum::Five, L"7" + std::wstring(m_decimalSeparator->Data()) + L"55", L"" },
|
||||
{ NumbersAndOperatorsEnum::Five, L"7" + std::wstring(m_decimalSeparator->Data()) + L"555", L"" },
|
||||
{ NumbersAndOperatorsEnum::Multiply, L"7" + std::wstring(m_decimalSeparator->Data()) + L"555",
|
||||
{ NumbersAndOperatorsEnum::Multiply,
|
||||
L"7" + std::wstring(m_decimalSeparator->Data()) + L"555",
|
||||
L"7" + std::wstring(m_decimalSeparator->Data()) + L"555 * " },
|
||||
{ NumbersAndOperatorsEnum::Three, L"3", L"7" + std::wstring(m_decimalSeparator->Data()) + L"555 * " },
|
||||
{ NumbersAndOperatorsEnum::Equals, L"22" + std::wstring(m_decimalSeparator->Data()) + L"665", L"" },
|
||||
@@ -549,8 +550,9 @@ namespace CalculatorUnitTests
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->HexDisplayValue), StringReference(L"FFFF FFFF FFFF FFFE"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"-2"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"1 777 777 777 777 777 777 776"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue),
|
||||
StringReference(L"1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1110"));
|
||||
VERIFY_ARE_EQUAL(
|
||||
Utils::GetStringValue(m_viewModel->BinaryDisplayValue),
|
||||
StringReference(L"1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1110"));
|
||||
VERIFY_ARE_EQUAL(m_viewModel->DisplayValue, StringReference(L"-2"));
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,8 @@ namespace UnitConverterUnitTests
|
||||
class TestUnitConverterConfigLoader : public IConverterDataLoader
|
||||
{
|
||||
public:
|
||||
TestUnitConverterConfigLoader() : m_loadDataCallCount(0)
|
||||
TestUnitConverterConfigLoader()
|
||||
: m_loadDataCallCount(0)
|
||||
{
|
||||
Category c1, c2;
|
||||
SetCategoryParams(&c1, 1, L"Length", true);
|
||||
@@ -492,8 +493,21 @@ namespace UnitConverterUnitTests
|
||||
|
||||
void UnitConverterTest::UnitConverterTestMaxDigitsReached()
|
||||
{
|
||||
ExecuteCommands({ Command::One, Command::Two, Command::Three, Command::Four, Command::Five, Command::Six, Command::Seven, Command::Eight, Command::Nine,
|
||||
Command::One, Command::Zero, Command::One, Command::One, Command::One, Command::Two });
|
||||
ExecuteCommands({ Command::One,
|
||||
Command::Two,
|
||||
Command::Three,
|
||||
Command::Four,
|
||||
Command::Five,
|
||||
Command::Six,
|
||||
Command::Seven,
|
||||
Command::Eight,
|
||||
Command::Nine,
|
||||
Command::One,
|
||||
Command::Zero,
|
||||
Command::One,
|
||||
Command::One,
|
||||
Command::One,
|
||||
Command::Two });
|
||||
|
||||
VERIFY_ARE_EQUAL(0, s_testVMCallback->GetMaxDigitsReachedCallCount());
|
||||
|
||||
@@ -504,8 +518,22 @@ namespace UnitConverterUnitTests
|
||||
|
||||
void UnitConverterTest::UnitConverterTestMaxDigitsReached_LeadingDecimal()
|
||||
{
|
||||
ExecuteCommands({ Command::Zero, Command::Decimal, Command::One, Command::Two, Command::Three, Command::Four, Command::Five, Command::Six,
|
||||
Command::Seven, Command::Eight, Command::Nine, Command::One, Command::Zero, Command::One, Command::One, Command::One });
|
||||
ExecuteCommands({ Command::Zero,
|
||||
Command::Decimal,
|
||||
Command::One,
|
||||
Command::Two,
|
||||
Command::Three,
|
||||
Command::Four,
|
||||
Command::Five,
|
||||
Command::Six,
|
||||
Command::Seven,
|
||||
Command::Eight,
|
||||
Command::Nine,
|
||||
Command::One,
|
||||
Command::Zero,
|
||||
Command::One,
|
||||
Command::One,
|
||||
Command::One });
|
||||
|
||||
VERIFY_ARE_EQUAL(0, s_testVMCallback->GetMaxDigitsReachedCallCount());
|
||||
|
||||
@@ -516,8 +544,22 @@ namespace UnitConverterUnitTests
|
||||
|
||||
void UnitConverterTest::UnitConverterTestMaxDigitsReached_TrailingDecimal()
|
||||
{
|
||||
ExecuteCommands({ Command::One, Command::Two, Command::Three, Command::Four, Command::Five, Command::Six, Command::Seven, Command::Eight, Command::Nine,
|
||||
Command::One, Command::Zero, Command::One, Command::One, Command::One, Command::Two, Command::Decimal });
|
||||
ExecuteCommands({ Command::One,
|
||||
Command::Two,
|
||||
Command::Three,
|
||||
Command::Four,
|
||||
Command::Five,
|
||||
Command::Six,
|
||||
Command::Seven,
|
||||
Command::Eight,
|
||||
Command::Nine,
|
||||
Command::One,
|
||||
Command::Zero,
|
||||
Command::One,
|
||||
Command::One,
|
||||
Command::One,
|
||||
Command::Two,
|
||||
Command::Decimal });
|
||||
|
||||
VERIFY_ARE_EQUAL(0, s_testVMCallback->GetMaxDigitsReachedCallCount());
|
||||
|
||||
@@ -528,8 +570,21 @@ namespace UnitConverterUnitTests
|
||||
|
||||
void UnitConverterTest::UnitConverterTestMaxDigitsReached_MultipleTimes()
|
||||
{
|
||||
ExecuteCommands({ Command::One, Command::Two, Command::Three, Command::Four, Command::Five, Command::Six, Command::Seven, Command::Eight, Command::Nine,
|
||||
Command::One, Command::Zero, Command::One, Command::One, Command::One, Command::Two });
|
||||
ExecuteCommands({ Command::One,
|
||||
Command::Two,
|
||||
Command::Three,
|
||||
Command::Four,
|
||||
Command::Five,
|
||||
Command::Six,
|
||||
Command::Seven,
|
||||
Command::Eight,
|
||||
Command::Nine,
|
||||
Command::One,
|
||||
Command::Zero,
|
||||
Command::One,
|
||||
Command::One,
|
||||
Command::One,
|
||||
Command::Two });
|
||||
|
||||
VERIFY_ARE_EQUAL(0, s_testVMCallback->GetMaxDigitsReachedCallCount());
|
||||
|
||||
|
@@ -262,7 +262,8 @@ private:
|
||||
bool m_active;
|
||||
|
||||
public:
|
||||
MockActivatable(bool active) : m_active(active)
|
||||
MockActivatable(bool active)
|
||||
: m_active(active)
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user