simplifying a function

Dramatic simplification of legacy code by separating code and data and applying some later C++.
Function removed from Application.cpp as it was in a anonymous namespace and could not easily be subjected to unit testing.
Added ProgramOptionsUtilities.h
This commit is contained in:
berniev
2023-03-08 08:50:46 +10:00
committed by wwmayer
parent eba80267ff
commit de1acd926e
5 changed files with 125 additions and 50 deletions

View File

@@ -0,0 +1,38 @@
#include "gtest/gtest.h"
#define FC_OS_MACOSX 1
#include "App/ProgramOptionsUtilities.h"
using namespace App::Util;
using Spr = std::pair<std::string, std::string>;
TEST(ApplicationTest, fCustomSyntaxLookup){
Spr res {customSyntax("-display")};
Spr exp {"display", "null"};
EXPECT_EQ(res,exp);
};
TEST(ApplicationTest, fCustomSyntaxMac){
Spr res {customSyntax("-psn_stuff")};
Spr exp {"psn", "stuff"};
EXPECT_EQ(res,exp);
};
TEST(ApplicationTest, fCustomSyntaxWidgetCount){
Spr res {customSyntax("-widgetcount")};
Spr exp {"widgetcount", ""};
EXPECT_EQ(res,exp);
}
TEST(ApplicationTest, fCustomSyntaxNotFound){
Spr res {customSyntax("-displayx")};
Spr exp {"", ""};
EXPECT_EQ(res,exp);
};
TEST(ApplicationTest, fCustomSyntaxAmpersand){
Spr res {customSyntax("@freddie")};
Spr exp {"response-file", "freddie"};
EXPECT_EQ(res,exp);
};
TEST(ApplicationTest, fCustomSyntaxEmptyIn){
Spr res {customSyntax("")};
Spr exp {"", ""};
EXPECT_EQ(res,exp);
};