Skip to content

Commit 26ddea4

Browse files
committed
style: Refactor App4Test introducing display_arguments convenience function
1 parent 4d2d473 commit 26ddea4

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Testing/Launcher/App4Test/Main.cpp.in

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ int check_unexpected_env_var(const char* varname)
8080
return EXIT_SUCCESS;
8181
}
8282

83+
void display_arguments(std::ostream& stream, int argc, char* argv[])
84+
{
85+
// Since tests are expecting the argument to be displayed as ""Argument passed: [arg1 [...]]", changing
86+
// the following may require to update the tests.
87+
stream << "Argument passed:";
88+
if (argc >= 2)
89+
{
90+
stream << argv[1]; // argName
91+
}
92+
for(int idx=2; idx < argc; idx++)
93+
{
94+
stream << " " << argv[idx];
95+
}
96+
stream << std::endl;
97+
}
98+
8399
int main(int argc, char** argv)
84100
{
85101
//std::cout << "Hello World !" << std::endl;
@@ -91,12 +107,8 @@ int main(int argc, char** argv)
91107
std::string argName(argv[1]);
92108
if (argName == "--foo")
93109
{
94-
std::cout << "Argument count: " << argc << " - Argument passed:" << argName;
95-
for(int i=2; i < argc; i++)
96-
{
97-
std::cout << " " << argv[i];
98-
}
99-
std::cout << std::endl;
110+
std::cout << "Argument count: " << argc << " - ";
111+
display_arguments(std::cout, argc, argv);
100112
}
101113
else if (argName == "--test-timeout")
102114
{

0 commit comments

Comments
 (0)