Cleaning up some UnitConverter code and making some of it more efficient. (#875)

This commit is contained in:
Scott Freeman
2019-12-18 04:19:28 -05:00
committed by Rudy Huyn
parent b6f9634e34
commit 3c6b5a808e
5 changed files with 107 additions and 108 deletions

View File

@@ -327,12 +327,12 @@ namespace UnitConverterUnitTests
// Test input escaping
void UnitConverterTest::UnitConverterTestQuote()
{
wstring input1 = L"Weight";
wstring output1 = L"Weight";
wstring input2 = L"{p}Weig;[ht|";
wstring output2 = L"{lb}p{rb}Weig{sc}{lc}ht{p}";
wstring input3 = L"{{{t;s}}},:]";
wstring output3 = L"{lb}{lb}{lb}t{sc}s{rb}{rb}{rb}{cm}{co}{rc}";
constexpr wstring_view input1 = L"Weight";
constexpr wstring_view output1 = L"Weight";
constexpr wstring_view input2 = L"{p}Weig;[ht|";
constexpr wstring_view output2 = L"{lb}p{rb}Weig{sc}{lc}ht{p}";
constexpr wstring_view input3 = L"{{{t;s}}},:]";
constexpr wstring_view output3 = L"{lb}{lb}{lb}t{sc}s{rb}{rb}{rb}{cm}{co}{rc}";
VERIFY_IS_TRUE(UnitConverter::Quote(input1) == output1);
VERIFY_IS_TRUE(UnitConverter::Quote(input2) == output2);
VERIFY_IS_TRUE(UnitConverter::Quote(input3) == output3);
@@ -341,9 +341,9 @@ namespace UnitConverterUnitTests
// Test output unescaping
void UnitConverterTest::UnitConverterTestUnquote()
{
wstring input1 = L"Weight";
wstring input2 = L"{p}Weig;[ht|";
wstring input3 = L"{{{t;s}}},:]";
constexpr wstring_view input1 = L"Weight";
constexpr wstring_view input2 = L"{p}Weig;[ht|";
constexpr wstring_view input3 = L"{{{t;s}}},:]";
VERIFY_IS_TRUE(UnitConverter::Unquote(input1) == input1);
VERIFY_IS_TRUE(UnitConverter::Unquote(UnitConverter::Quote(input1)) == input1);
VERIFY_IS_TRUE(UnitConverter::Unquote(UnitConverter::Quote(input2)) == input2);

View File

@@ -227,7 +227,7 @@ void UnitConverterMock::SwitchActive(const std::wstring& newValue)
return L"TEST";
};
void UnitConverterMock::RestoreUserPreferences(_In_ const std::wstring& /*userPreferences*/){};
void UnitConverterMock::RestoreUserPreferences(_In_ std::wstring_view /*userPreferences*/){};
void UnitConverterMock::SendCommand(UCM::Command command)
{

View File

@@ -35,7 +35,7 @@ namespace CalculatorUnitTests
void SetCurrentUnitTypes(const UCM::Unit& fromType, const UCM::Unit& toType) override;
void SwitchActive(const std::wstring& newValue);
std::wstring SaveUserPreferences() override;
void RestoreUserPreferences(_In_ const std::wstring& userPreferences) override;
void RestoreUserPreferences(_In_ std::wstring_view userPreferences) override;
void SendCommand(UCM::Command command) override;
void SetViewModelCallback(const std::shared_ptr<UCM::IUnitConverterVMCallback>& newCallback) override;
void SetViewModelCurrencyCallback(_In_ const std::shared_ptr<UCM::IViewModelCurrencyCallback>& /*newCallback*/) override