increasing coverage

This commit is contained in:
Ignacio Rodriguez 2020-11-09 19:43:19 +07:00
parent 387a7f7e69
commit af221bd94f

View file

@ -15,8 +15,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <functional>
#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<const char *, std::function<bool(ToolArgs const &)>> 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));
}
}