CopyPasteManagerTest fails to test all values (#269)
CopyPasteManager unit tests were not fully run, the first item of arrays were never tested. (Luckily, the not-tested values were ok). Updated from using a pre-decrement while loop to using a standard for loop with an iterator.
This commit is contained in:
parent
67fa2286eb
commit
a80d082242
@ -25,30 +25,17 @@ namespace CalculatorUnitTests
|
|||||||
|
|
||||||
#define ASSERT_POSITIVE_TESTCASES(func, dataSet) \
|
#define ASSERT_POSITIVE_TESTCASES(func, dataSet) \
|
||||||
{\
|
{\
|
||||||
int size = sizeof(dataSet)/sizeof(*dataSet);\
|
for(auto data : dataSet)\
|
||||||
while(--size)\
|
|
||||||
{\
|
{\
|
||||||
VERIFY_ARE_EQUAL(func(dataSet[size]), dataSet[size]);\
|
VERIFY_ARE_EQUAL(func(data), data);\
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ASSERT_NEGATIVE_TESTCASES(func, dataSet) \
|
#define ASSERT_NEGATIVE_TESTCASES(func, dataSet) \
|
||||||
{\
|
{\
|
||||||
int size = sizeof(dataSet)/sizeof(*dataSet);\
|
for(auto data : dataSet)\
|
||||||
while(--size)\
|
|
||||||
{\
|
{\
|
||||||
VERIFY_ARE_EQUAL(func(dataSet[size]), StringReference(L"NoOp"));\
|
VERIFY_ARE_EQUAL(func(data), StringReference(L"NoOp"));\
|
||||||
}\
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns a iterator from end
|
|
||||||
#define START_LOOP(dataSet)\
|
|
||||||
{\
|
|
||||||
int size = sizeof(dataSet)/sizeof(*dataSet);\
|
|
||||||
while(--size)\
|
|
||||||
{
|
|
||||||
|
|
||||||
#define END_LOOP\
|
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,15 +437,16 @@ namespace CalculatorUnitTests
|
|||||||
// Doesn't have test where converter is involved. Will add such a test later.
|
// Doesn't have test where converter is involved. Will add such a test later.
|
||||||
StandardCalculatorViewModel^ scvm = ref new StandardCalculatorViewModel();
|
StandardCalculatorViewModel^ scvm = ref new StandardCalculatorViewModel();
|
||||||
scvm->IsStandard = true;
|
scvm->IsStandard = true;
|
||||||
String^ input[] = { L"123", L"12345", L"123+456", L"1,234", L"1 2 3", L"\n\r1,234\n", L"\n 1+\n2 ", L"1\"2" };
|
String^ inputs[] = { L"123", L"12345", L"123+456", L"1,234", L"1 2 3", L"\n\r1,234\n", L"\n 1+\n2 ", L"1\"2" };
|
||||||
|
|
||||||
START_LOOP(input)
|
for (String^ &input : inputs)
|
||||||
|
{
|
||||||
// paste number in standard mode and then validate the pastability of displayed number for other modes
|
// paste number in standard mode and then validate the pastability of displayed number for other modes
|
||||||
scvm->OnPaste(input[size], ViewMode::Standard);
|
scvm->OnPaste(input, ViewMode::Standard);
|
||||||
VERIFY_ARE_EQUAL(ValidateStandardPasteExpression(scvm->DisplayValue), scvm->DisplayValue);
|
VERIFY_ARE_EQUAL(ValidateStandardPasteExpression(scvm->DisplayValue), scvm->DisplayValue);
|
||||||
VERIFY_ARE_EQUAL(ValidateScientificPasteExpression(scvm->DisplayValue), scvm->DisplayValue);
|
VERIFY_ARE_EQUAL(ValidateScientificPasteExpression(scvm->DisplayValue), scvm->DisplayValue);
|
||||||
VERIFY_ARE_EQUAL(ValidateProgrammerHexQwordPasteExpression(scvm->DisplayValue), scvm->DisplayValue);
|
VERIFY_ARE_EQUAL(ValidateProgrammerHexQwordPasteExpression(scvm->DisplayValue), scvm->DisplayValue);
|
||||||
END_LOOP
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user