From ff16a72271f097644195b118d799241c7fb74964 Mon Sep 17 00:00:00 2001 From: DevBoiAgru <79085233+DevBoiAgru@users.noreply.github.com> Date: Tue, 24 Sep 2024 07:33:47 +0530 Subject: [PATCH] Add Angstroms Length-Converter option (#2229) * Add Length_Angstrom as a new unit constant Adds Angstrom as a length unit to the list of unit constants in UnitConverterDataConstants.h file. * Add Angstrom unit to Length units in UnitConverterDataLoader.cpp Adds the Angstrom unit of length to the list of length units in UnitConverterDataLoader.cpp and its conversion data is added to the GetConversionData() function. It is assigned the value of 15. * Add Angstrom as a Unit of Length Adds new data entries to Resources.resw for unit abbreviation of Angstrom, and the unit name for Angstrom. * Add conversion data "Meters-Angstroms" in Test.resw Adds new data entry for "Meters-Angstroms" to Test.resw file * Changes order of units of Length to add Angstroms This commit changes the order of the units of length so that Angstrom is before Nanometers. Increments orders of all other units by 1 and sets order of Angstroms to 1. * Fixes 'TestStandardUnitConverterAndDateViewModels' test case failing This commit fixes the "TestStandardUnitConverterAndDateViewModels" failing by introducing a new resource entry to the Test.resw file. These changes needed to be made because adding the new unit changed the order of units, hence the test case expected a different value, since it was converting other units. --- .../DataLoaders/UnitConverterDataConstants.h | 5 +-- .../DataLoaders/UnitConverterDataLoader.cpp | 31 ++++++++++--------- src/Calculator/Resources/en-US/Resources.resw | 8 +++++ src/CalculatorUnitTests/Test.resw | 7 +++-- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/CalcViewModel/DataLoaders/UnitConverterDataConstants.h b/src/CalcViewModel/DataLoaders/UnitConverterDataConstants.h index 057b6da02..db01aab77 100644 --- a/src/CalcViewModel/DataLoaders/UnitConverterDataConstants.h +++ b/src/CalcViewModel/DataLoaders/UnitConverterDataConstants.h @@ -165,8 +165,9 @@ namespace CalculatorApp Data_Zetabytes = UnitStart + 164, Area_Pyeong = UnitStart + 165, Energy_Kilowatthour = UnitStart + 166, - Data_Nibble = UnitStart + 167, - UnitEnd = Data_Nibble + Data_Nibble = UnitStart + 167, + Length_Angstrom = UnitStart + 168, + UnitEnd = Length_Angstrom }; } } diff --git a/src/CalcViewModel/DataLoaders/UnitConverterDataLoader.cpp b/src/CalcViewModel/DataLoaders/UnitConverterDataLoader.cpp index a613a61a4..da19fe591 100644 --- a/src/CalcViewModel/DataLoaders/UnitConverterDataLoader.cpp +++ b/src/CalcViewModel/DataLoaders/UnitConverterDataLoader.cpp @@ -400,53 +400,55 @@ void UnitConverterDataLoader::GetUnits(_In_ unordered_map lengthUnits; + lengthUnits.push_back(OrderedUnit{ + UnitConverterUnits::Length_Angstrom, GetLocalizedStringName(L"UnitName_Angstrom"), GetLocalizedStringName(L"UnitAbbreviation_Angstrom"), 1 }); lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Centimeter, GetLocalizedStringName(L"UnitName_Centimeter"), GetLocalizedStringName(L"UnitAbbreviation_Centimeter"), - 4, + 5, useUSCustomary, useSI, false }); lengthUnits.push_back( - OrderedUnit{ UnitConverterUnits::Length_Foot, GetLocalizedStringName(L"UnitName_Foot"), GetLocalizedStringName(L"UnitAbbreviation_Foot"), 8 }); + OrderedUnit{ UnitConverterUnits::Length_Foot, GetLocalizedStringName(L"UnitName_Foot"), GetLocalizedStringName(L"UnitAbbreviation_Foot"), 9 }); lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Inch, GetLocalizedStringName(L"UnitName_Inch"), GetLocalizedStringName(L"UnitAbbreviation_Inch"), - 7, + 8, useSI, useUSCustomary, false }); lengthUnits.push_back(OrderedUnit{ - UnitConverterUnits::Length_Kilometer, GetLocalizedStringName(L"UnitName_Kilometer"), GetLocalizedStringName(L"UnitAbbreviation_Kilometer"), 6 }); + UnitConverterUnits::Length_Kilometer, GetLocalizedStringName(L"UnitName_Kilometer"), GetLocalizedStringName(L"UnitAbbreviation_Kilometer"), 7 }); lengthUnits.push_back( - OrderedUnit{ UnitConverterUnits::Length_Meter, GetLocalizedStringName(L"UnitName_Meter"), GetLocalizedStringName(L"UnitAbbreviation_Meter"), 5 }); + OrderedUnit{ UnitConverterUnits::Length_Meter, GetLocalizedStringName(L"UnitName_Meter"), GetLocalizedStringName(L"UnitAbbreviation_Meter"), 6 }); lengthUnits.push_back( - OrderedUnit{ UnitConverterUnits::Length_Micron, GetLocalizedStringName(L"UnitName_Micron"), GetLocalizedStringName(L"UnitAbbreviation_Micron"), 2 }); + OrderedUnit{ UnitConverterUnits::Length_Micron, GetLocalizedStringName(L"UnitName_Micron"), GetLocalizedStringName(L"UnitAbbreviation_Micron"), 3 }); lengthUnits.push_back( - OrderedUnit{ UnitConverterUnits::Length_Mile, GetLocalizedStringName(L"UnitName_Mile"), GetLocalizedStringName(L"UnitAbbreviation_Mile"), 10 }); + OrderedUnit{ UnitConverterUnits::Length_Mile, GetLocalizedStringName(L"UnitName_Mile"), GetLocalizedStringName(L"UnitAbbreviation_Mile"), 11 }); lengthUnits.push_back(OrderedUnit{ - UnitConverterUnits::Length_Millimeter, GetLocalizedStringName(L"UnitName_Millimeter"), GetLocalizedStringName(L"UnitAbbreviation_Millimeter"), 3 }); + UnitConverterUnits::Length_Millimeter, GetLocalizedStringName(L"UnitName_Millimeter"), GetLocalizedStringName(L"UnitAbbreviation_Millimeter"), 4 }); lengthUnits.push_back(OrderedUnit{ - UnitConverterUnits::Length_Nanometer, GetLocalizedStringName(L"UnitName_Nanometer"), GetLocalizedStringName(L"UnitAbbreviation_Nanometer"), 1 }); + UnitConverterUnits::Length_Nanometer, GetLocalizedStringName(L"UnitName_Nanometer"), GetLocalizedStringName(L"UnitAbbreviation_Nanometer"), 2 }); lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_NauticalMile, GetLocalizedStringName(L"UnitName_NauticalMile"), GetLocalizedStringName(L"UnitAbbreviation_NauticalMile"), - 11 }); + 12 }); lengthUnits.push_back( - OrderedUnit{ UnitConverterUnits::Length_Yard, GetLocalizedStringName(L"UnitName_Yard"), GetLocalizedStringName(L"UnitAbbreviation_Yard"), 9 }); + OrderedUnit{ UnitConverterUnits::Length_Yard, GetLocalizedStringName(L"UnitName_Yard"), GetLocalizedStringName(L"UnitAbbreviation_Yard"), 10 }); lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Paperclip, GetLocalizedStringName(L"UnitName_Paperclip"), GetLocalizedStringName(L"UnitAbbreviation_Paperclip"), - 12, + 13, false, false, true }); lengthUnits.push_back(OrderedUnit{ - UnitConverterUnits::Length_Hand, GetLocalizedStringName(L"UnitName_Hand"), GetLocalizedStringName(L"UnitAbbreviation_Hand"), 13, false, false, true }); + UnitConverterUnits::Length_Hand, GetLocalizedStringName(L"UnitName_Hand"), GetLocalizedStringName(L"UnitAbbreviation_Hand"), 14, false, false, true }); lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_JumboJet, GetLocalizedStringName(L"UnitName_JumboJet"), GetLocalizedStringName(L"UnitAbbreviation_JumboJet"), - 14, + 15, false, false, true }); @@ -855,6 +857,7 @@ void UnitConverterDataLoader::GetConversionData(_In_ unordered_mapcup (US) An abbreviation for a measurement unit of volume + + A + An abbreviation for a measurement unit of length + ac An abbreviation for a measurement unit of volume @@ -2241,6 +2245,10 @@ Nanometers A measurement unit for length. (Please choose the most appropriate plural form to fit any number between 0 and 999,999,999,999,999) + + Angstroms + A measurement unit for length. (Please choose the most appropriate plural form to fit any number between 0 and 999,999,999,999,999) + Nautical miles A measurement unit for length. (Please choose the most appropriate plural form to fit any number between 0 and 999,999,999,999,999) diff --git a/src/CalculatorUnitTests/Test.resw b/src/CalculatorUnitTests/Test.resw index bc8b6f69c..346b24c0a 100644 --- a/src/CalculatorUnitTests/Test.resw +++ b/src/CalculatorUnitTests/Test.resw @@ -324,6 +324,9 @@ 0.000000001 + + 0.0000000001 + 0.01 @@ -588,8 +591,8 @@ 1 - - 0.003 + + 0.3 3600000