2
* Copyright (C) 2015 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#include <gtest/gtest.h>
19
#include <argvHelper.h>
21
using namespace qtmir;
23
TEST(ArgvHelperTest, StripsCorrectly)
26
const char *argv[6] = { "/usr/bin/unity8", "-fullscreen", "--debug",
27
"--platform-input-lib=/path/to/lib.so", "-testability", nullptr };
29
const int filteredArgc = 2;
30
const char *filteredArgv[3] = { "-fullscreen", "-testability", nullptr };
32
editArgvToMatch(argc, const_cast<char**>(argv), filteredArgc, filteredArgv);
35
EXPECT_EQ(argv[0], "/usr/bin/unity8");
36
EXPECT_EQ(argv[1], "-fullscreen");
37
EXPECT_EQ(argv[2], "-testability");
38
EXPECT_EQ(argv[3], nullptr);
41
TEST(ArgvHelperTest, NothingToStrip)
44
const char *argv[5] = { "/usr/bin/unity8", "-fullscreen", "--multisample", "-testability", nullptr };
46
const int filteredArgc = 3;
47
const char *filteredArgv[4] = { "-fullscreen", "-testability", "--multisample", nullptr };
49
editArgvToMatch(argc, const_cast<char**>(argv), filteredArgc, filteredArgv);
52
EXPECT_EQ(argv[0], "/usr/bin/unity8");
53
EXPECT_EQ(argv[1], "-fullscreen");
54
EXPECT_EQ(argv[2], "-testability");
55
EXPECT_EQ(argv[3], "--multisample");
56
EXPECT_EQ(argv[4], nullptr);
59
TEST(ArgvHelperTest, NothingToDo)
62
const char *argv[2] = { "/usr/bin/unity8", nullptr };
64
const int filteredArgc = 0;
65
const char *filteredArgv[1] = { nullptr };
67
editArgvToMatch(argc, const_cast<char**>(argv), filteredArgc, filteredArgv);
70
EXPECT_EQ(argv[0], "/usr/bin/unity8");
71
EXPECT_EQ(argv[1], nullptr);