From af221bd94ffb9a3bdf4f07267b81ca810d54cd6d Mon Sep 17 00:00:00 2001 From: Ignacio Rodriguez Date: Mon, 9 Nov 2020 19:43:19 +0700 Subject: [PATCH] increasing coverage --- src/test/unittests/synergy/ArgParserTests.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/unittests/synergy/ArgParserTests.cpp b/src/test/unittests/synergy/ArgParserTests.cpp index 8b1211427..7069d1ad6 100644 --- a/src/test/unittests/synergy/ArgParserTests.cpp +++ b/src/test/unittests/synergy/ArgParserTests.cpp @@ -15,8 +15,11 @@ * along with this program. If not, see . */ +#include + #include "synergy/ArgParser.h" #include "synergy/ArgsBase.h" +#include "synergy/ToolArgs.h" #include "test/global/gtest.h" @@ -205,3 +208,21 @@ TEST(ArgParserTests, assembleCommand_stringArrayWithSpace_returnCommand) EXPECT_EQ("\"stub1 space\" stub2 \"stub3 space\"", command); } +TEST(ArgParserTests, parseToolArgs_matches_correspondingly) +{ + ArgParser parser(nullptr); + std::map> tests = { + {"--get-active-desktop", [](ToolArgs const &a){ return a.m_printActiveDesktopName; }}, + {"--get-installed-dir", [](ToolArgs const &a){ return a.m_getInstalledDir; }}, + {"--get-profile-dir", [](ToolArgs const &a){ return a.m_getProfileDir; }}, + {"--get-arch", [](ToolArgs const &a){ return a.m_getArch; }} + }; + for (auto const &test: tests) { + ToolArgs toolArgs; + EXPECT_FALSE(test.second(toolArgs)); + const char *twoArgs[2] {"syntool", test.first}; + EXPECT_TRUE(parser.parseToolArgs(toolArgs, 2, twoArgs)); + EXPECT_TRUE(test.second(toolArgs)); + } +} +