From 62bb4d4001b82247df05fe80d6c12faae982afad Mon Sep 17 00:00:00 2001 From: FallJock <97912576+FallJock@users.noreply.github.com> Date: Sat, 7 Dec 2024 15:51:16 +0300 Subject: [PATCH] Edit UnitConverterTestUnitTypeSwitching (Edit UnitConverterTest.cpp) The test has been improved in the code, now it checks for changes after the function of SwitchActive and fits a new value separately into the to field after the function of SwitchActive When I tried to edit the SwitchActive function, I removed the swap of fromType and toType. And I ran all the tests. And only UnitConverterTestScientificInputs detected a value error when using the SwitchActive function. --- src/CalculatorUnitTests/UnitConverterTest.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/CalculatorUnitTests/UnitConverterTest.cpp b/src/CalculatorUnitTests/UnitConverterTest.cpp index c0775092..65abe930 100644 --- a/src/CalculatorUnitTests/UnitConverterTest.cpp +++ b/src/CalculatorUnitTests/UnitConverterTest.cpp @@ -347,13 +347,15 @@ namespace UnitConverterUnitTests // Test switching of unit types void UnitConverterTest::UnitConverterTestUnitTypeSwitching() { - // Enter 57 into the from field, then switch focus to the to field (making it the new from field) - s_unitConverter->SendCommand(Command::Five); - s_unitConverter->SendCommand(Command::Seven); - s_unitConverter->SwitchActive(wstring(L"57")); - // Now set unit conversion to go from kilograms to pounds + // Now set unit conversion to go from pounds to kilograms s_unitConverter->SetCurrentCategory(s_testWeight); - s_unitConverter->SetCurrentUnitTypes(s_testKilograms, s_testPounds); + s_unitConverter->SetCurrentUnitTypes(s_testPounds, s_testKilograms); + // Enter 5 into the from field, then switch focus to the to field (making it the new from field) (switch focus to kilograms) + s_unitConverter->SendCommand(Command::Five); + s_unitConverter->SwitchActive(wstring(L"2.26796")); + VERIFY_IS_TRUE(s_testVMCallback->CheckDisplayValues(wstring(L"5"), wstring(L"2.26796"))); + VERIFY_IS_TRUE(s_testVMCallback->CheckSuggestedValues(vector>())); + // Enter 5 again into the to field s_unitConverter->SendCommand(Command::Five); VERIFY_IS_TRUE(s_testVMCallback->CheckDisplayValues(wstring(L"5"), wstring(L"11.0231"))); VERIFY_IS_TRUE(s_testVMCallback->CheckSuggestedValues(vector>()));