diff --git a/src/CalculatorUnitTests/CopyPasteManagerTest.cpp b/src/CalculatorUnitTests/CopyPasteManagerTest.cpp index 9f3afc9..4e53dff 100644 --- a/src/CalculatorUnitTests/CopyPasteManagerTest.cpp +++ b/src/CalculatorUnitTests/CopyPasteManagerTest.cpp @@ -25,30 +25,17 @@ namespace CalculatorUnitTests #define ASSERT_POSITIVE_TESTCASES(func, dataSet) \ {\ - int size = sizeof(dataSet)/sizeof(*dataSet);\ - while(--size)\ + for(auto data : dataSet)\ {\ - VERIFY_ARE_EQUAL(func(dataSet[size]), dataSet[size]);\ + VERIFY_ARE_EQUAL(func(data), data);\ }\ } #define ASSERT_NEGATIVE_TESTCASES(func, dataSet) \ {\ - int size = sizeof(dataSet)/sizeof(*dataSet);\ - while(--size)\ + for(auto data : dataSet)\ {\ - VERIFY_ARE_EQUAL(func(dataSet[size]), StringReference(L"NoOp"));\ - }\ -} - -// returns a iterator from end -#define START_LOOP(dataSet)\ -{\ - int size = sizeof(dataSet)/sizeof(*dataSet);\ - while(--size)\ - { - -#define END_LOOP\ + VERIFY_ARE_EQUAL(func(data), StringReference(L"NoOp"));\ }\ } @@ -450,15 +437,16 @@ namespace CalculatorUnitTests // Doesn't have test where converter is involved. Will add such a test later. StandardCalculatorViewModel^ scvm = ref new StandardCalculatorViewModel(); 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 - scvm->OnPaste(input[size], ViewMode::Standard); + scvm->OnPaste(input, ViewMode::Standard); VERIFY_ARE_EQUAL(ValidateStandardPasteExpression(scvm->DisplayValue), scvm->DisplayValue); VERIFY_ARE_EQUAL(ValidateScientificPasteExpression(scvm->DisplayValue), scvm->DisplayValue); VERIFY_ARE_EQUAL(ValidateProgrammerHexQwordPasteExpression(scvm->DisplayValue), scvm->DisplayValue); - END_LOOP + } }