CommandLineTests.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/UnitTest/TestTypes.h>
  9. #include <AzCore/Settings/CommandLine.h>
  10. namespace UnitTest
  11. {
  12. class CommandLineTests
  13. : public LeakDetectionFixture
  14. {
  15. };
  16. TEST_F(CommandLineTests, CommandLineParser_Sanity)
  17. {
  18. AZ::CommandLine cmd;
  19. EXPECT_FALSE(cmd.HasSwitch(""));
  20. EXPECT_EQ(cmd.GetNumSwitchValues("haha"), 0);
  21. AZ_TEST_START_TRACE_SUPPRESSION;
  22. EXPECT_EQ(cmd.GetSwitchValue("haha", 0), AZStd::string());
  23. AZ_TEST_STOP_TRACE_SUPPRESSION(1);
  24. EXPECT_EQ(cmd.GetNumMiscValues(), 0);
  25. AZ_TEST_START_TRACE_SUPPRESSION;
  26. EXPECT_EQ(cmd.GetMiscValue(1), AZStd::string());
  27. AZ_TEST_STOP_TRACE_SUPPRESSION(1);
  28. }
  29. TEST_F(CommandLineTests, CommandLineParser_Switches_Simple)
  30. {
  31. AZ::CommandLine cmd;
  32. const char* argValues[] = {
  33. "programname.exe", "--switch1", "test", "--switch2", "test2", "--switch3", "tEST3"
  34. };
  35. cmd.Parse(7, const_cast<char**>(argValues));
  36. EXPECT_FALSE(cmd.HasSwitch("switch4"));
  37. EXPECT_TRUE(cmd.HasSwitch("switch3"));
  38. EXPECT_TRUE(cmd.HasSwitch("sWITCH2")); // expect case insensitive
  39. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  40. EXPECT_EQ(cmd.GetNumSwitchValues("switch1"), 1);
  41. EXPECT_EQ(cmd.GetNumSwitchValues("switch2"), 1);
  42. EXPECT_EQ(cmd.GetNumSwitchValues("switch3"), 1);
  43. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "test");
  44. EXPECT_EQ(cmd.GetSwitchValue("switch2", 0), "test2");
  45. EXPECT_EQ(cmd.GetSwitchValue("switch3", 0), "tEST3"); // retain case in values.
  46. AZ_TEST_START_TRACE_SUPPRESSION;
  47. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), AZStd::string());
  48. EXPECT_EQ(cmd.GetSwitchValue("switch2", 1), AZStd::string());
  49. EXPECT_EQ(cmd.GetSwitchValue("switch3", 1), AZStd::string());
  50. AZ_TEST_STOP_TRACE_SUPPRESSION(3);
  51. }
  52. TEST_F(CommandLineTests, CommandLineParser_MiscValues_Simple)
  53. {
  54. AZ::CommandLine cmd{ AZ::Settings::CommandLineOptionPrefixArray{ "-" } };
  55. const char* argValues[] = {
  56. "programname.exe", "-switch1", "test", "miscvalue1", "miscvalue2"
  57. };
  58. cmd.Parse(5, const_cast<char**>(argValues));
  59. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  60. EXPECT_EQ(cmd.GetNumSwitchValues("switch1"), 1);
  61. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "test");
  62. EXPECT_EQ(cmd.GetNumMiscValues(), 2);
  63. EXPECT_EQ(cmd.GetMiscValue(0), "miscvalue1");
  64. EXPECT_EQ(cmd.GetMiscValue(1), "miscvalue2");
  65. }
  66. TEST_F(CommandLineTests, CommandLineParser_Complex)
  67. {
  68. AZ::CommandLine cmd{ AZ::Settings::CommandLineOptionPrefixArray{ "--", "-", "/" } };
  69. const char* argValues[] = {
  70. "programname.exe", "-switch1", "test", "--switch1", "test2", "/switch2", "otherswitch", "miscvalue", "/switch3=abc,def", "miscvalue2", "/switch3", "hij,klm"
  71. };
  72. cmd.Parse(12, const_cast<char**>(argValues));
  73. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  74. EXPECT_TRUE(cmd.HasSwitch("switch2"));
  75. EXPECT_EQ(cmd.GetNumMiscValues(), 2);
  76. EXPECT_EQ(cmd.GetMiscValue(0), "miscvalue");
  77. EXPECT_EQ(cmd.GetMiscValue(1), "miscvalue2");
  78. EXPECT_EQ(cmd.GetNumSwitchValues("switch1"), 2);
  79. EXPECT_EQ(cmd.GetNumSwitchValues("switch2"), 1);
  80. EXPECT_EQ(cmd.GetNumSwitchValues("switch3"), 4);
  81. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "test");
  82. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), "test2");
  83. EXPECT_EQ(cmd.GetSwitchValue("switch2", 0), "otherswitch");
  84. EXPECT_EQ(cmd.GetSwitchValue("switch3", 0), "abc");
  85. EXPECT_EQ(cmd.GetSwitchValue("switch3", 1), "def");
  86. EXPECT_EQ(cmd.GetSwitchValue("switch3", 2), "hij");
  87. EXPECT_EQ(cmd.GetSwitchValue("switch3", 3), "klm");
  88. }
  89. TEST_F(CommandLineTests, CommandLineParser_WhitespaceTolerant)
  90. {
  91. AZ::CommandLine cmd{ AZ::Settings::CommandLineOptionPrefixArray{ "--", "-", "/" } };
  92. const char* argValues[] = {
  93. "programname.exe", "/switch1 ", "test ", " /switch1", " test2", " --switch1", " abc, def ", " /switch1 = abc, def "
  94. };
  95. cmd.Parse(8, const_cast<char**>(argValues));
  96. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  97. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "test");
  98. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), "test2");
  99. EXPECT_EQ(cmd.GetSwitchValue("switch1", 2), "abc");
  100. EXPECT_EQ(cmd.GetSwitchValue("switch1", 3), "def");
  101. // note: Every switch must appear in the order it is given, even duplicates.
  102. EXPECT_EQ(cmd.GetSwitchValue("switch1", 4), "abc");
  103. EXPECT_EQ(cmd.GetSwitchValue("switch1", 5), "def");
  104. }
  105. TEST_F(CommandLineTests, CommandLineParser_CustomCommandOption_IsUsedInsteadOfDefault)
  106. {
  107. AZ::CommandLine cmd{ AZ::Settings::CommandLineOptionPrefixArray{ "+" } };
  108. const char* argValues[] =
  109. {
  110. "programname.exe", "-fakeswitch1", "test", "--fakeswitch2", "test2", "+realswitch1", "othervalue", "miscvalue",
  111. "/fakeswitch3=abc,def", "miscvalue2", "+-realswitch2", "More,Real"
  112. };
  113. cmd.Parse(aznumeric_cast<int>(AZStd::size(argValues)), const_cast<char**>(AZStd::data(argValues)));
  114. EXPECT_FALSE(cmd.HasSwitch("fakeswitch1"));
  115. EXPECT_FALSE(cmd.HasSwitch("fakeswitch2"));
  116. EXPECT_FALSE(cmd.HasSwitch("fakeswitch3"));
  117. EXPECT_TRUE(cmd.HasSwitch("realswitch1"));
  118. EXPECT_TRUE(cmd.HasSwitch("-realswitch2"));
  119. EXPECT_EQ(7, cmd.GetNumMiscValues());
  120. EXPECT_EQ("-fakeswitch1", cmd.GetMiscValue(0));
  121. EXPECT_EQ("test", cmd.GetMiscValue(1));
  122. EXPECT_EQ("--fakeswitch2", cmd.GetMiscValue(2));
  123. EXPECT_EQ("test2", cmd.GetMiscValue(3));
  124. EXPECT_EQ("miscvalue", cmd.GetMiscValue(4));
  125. EXPECT_EQ("/fakeswitch3=abc,def", cmd.GetMiscValue(5));
  126. EXPECT_EQ("miscvalue2", cmd.GetMiscValue(6));
  127. EXPECT_EQ(1, cmd.GetNumSwitchValues("realswitch1"));
  128. EXPECT_EQ(2, cmd.GetNumSwitchValues("-realswitch2"));
  129. EXPECT_EQ("othervalue", cmd.GetSwitchValue("realswitch1", 0));
  130. EXPECT_EQ("More", cmd.GetSwitchValue("-realswitch2", 0));
  131. EXPECT_EQ("Real", cmd.GetSwitchValue("-realswitch2", 1));
  132. }
  133. TEST_F(CommandLineTests, CommandLineParser_QuoteBoundNoEqualWithComma_Success)
  134. {
  135. AZ::CommandLine cmd;
  136. const char* argValues[] = {
  137. "programname.exe", " -switch1 " ,"\"acb,def\""
  138. };
  139. cmd.Parse(3, const_cast<char**>(argValues));
  140. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  141. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "acb,def");
  142. }
  143. TEST_F(CommandLineTests, CommandLineParser_QuoteBoundEqualWithCommaNoSpace_Success)
  144. {
  145. AZ::CommandLine cmd;
  146. const char* argValues[] = {
  147. "programname.exe", " -switch1=\"abc,fde\""
  148. };
  149. cmd.Parse(2, const_cast<char**>(argValues));
  150. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  151. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "abc,fde");
  152. }
  153. TEST_F(CommandLineTests, CommandLineParser_QuoteBoundEqualWithCommaSpace_Success)
  154. {
  155. AZ::CommandLine cmd;
  156. const char* argValues[] = {
  157. "programname.exe", " -switch1=\"abc, def\""
  158. };
  159. cmd.Parse(2, const_cast<char**>(argValues));
  160. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  161. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "abc, def");
  162. }
  163. TEST_F(CommandLineTests, CommandLineParser_SingleQuoteEqualWithCommaSpace_Tokenized)
  164. {
  165. AZ::CommandLine cmd;
  166. const char* argValues[] = {
  167. "programname.exe", " -switch1=\"abc, def"
  168. };
  169. cmd.Parse(2, const_cast<char**>(argValues));
  170. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  171. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "\"abc");
  172. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), "def");
  173. }
  174. TEST_F(CommandLineTests, CommandLineParser_SingleQuoteEqualWithCommaNoSpace_Tokenized)
  175. {
  176. AZ::CommandLine cmd;
  177. const char* argValues[] = {
  178. "programname.exe", " -switch1=\"abc,def"
  179. };
  180. cmd.Parse(2, const_cast<char**>(argValues));
  181. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  182. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "\"abc");
  183. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), "def");
  184. }
  185. TEST_F(CommandLineTests, CommandLineParser_SingleQuoteNoEqualWithCommaNoSpace_Tokenized)
  186. {
  187. AZ::CommandLine cmd;
  188. const char* argValues[] = {
  189. "programname.exe", " -switch1", " \"abc,def"
  190. };
  191. cmd.Parse(3, const_cast<char**>(argValues));
  192. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  193. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "\"abc");
  194. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), "def");
  195. }
  196. TEST_F(CommandLineTests, CommandLineParser_SingleQuoteNoEqualWithSemicolonNoSpace_Tokenized)
  197. {
  198. AZ::CommandLine cmd;
  199. const char* argValues[] = {
  200. "programname.exe", " -switch1", " \"abc;def"
  201. };
  202. cmd.Parse(3, const_cast<char**>(argValues));
  203. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  204. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "\"abc");
  205. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), "def");
  206. }
  207. TEST_F(CommandLineTests, CommandLineParser_SingleQuoteNoEqualWithCommaSpace_Tokenized)
  208. {
  209. AZ::CommandLine cmd;
  210. const char* argValues[] = {
  211. "programname.exe", " -switch1", "\"abc, def"
  212. };
  213. cmd.Parse(3, const_cast<char**>(argValues));
  214. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  215. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "\"abc");
  216. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), "def");
  217. }
  218. TEST_F(CommandLineTests, CommandLineParser_DoubleQuoteNoEqual_Blank)
  219. {
  220. AZ::CommandLine cmd;
  221. const char* argValues[] = {
  222. "programname.exe", "-switch1", "\"\""
  223. };
  224. cmd.Parse(3, const_cast<char**>(argValues));
  225. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  226. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "");
  227. }
  228. TEST_F(CommandLineTests, CommandLineParser_DoubleQuote_Blank)
  229. {
  230. AZ::CommandLine cmd;
  231. const char* argValues[] = {
  232. "programname.exe", " -switch1=\"\"", " -switch2", "\"\""
  233. };
  234. cmd.Parse(4, const_cast<char**>(argValues));
  235. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  236. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "");
  237. EXPECT_TRUE(cmd.HasSwitch("switch2"));
  238. EXPECT_EQ(cmd.GetSwitchValue("switch2", 0), "");
  239. }
  240. TEST_F(CommandLineTests, CommandLineParser_DoubleQuoteEqualComma_Comma)
  241. {
  242. AZ::CommandLine cmd;
  243. const char* argValues[] = {
  244. "programname.exe", " -switch1=\",\""
  245. };
  246. cmd.Parse(2, const_cast<char**>(argValues));
  247. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  248. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), ",");
  249. }
  250. TEST_F(CommandLineTests, CommandLineParser_SingleDoubleQuote_Success)
  251. {
  252. AZ::CommandLine cmd;
  253. const char* argValues[] = {
  254. "programname.exe", " -switch1=\"", " -switch2", "\""
  255. };
  256. cmd.Parse(4, const_cast<char**>(argValues));
  257. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  258. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "\"");
  259. EXPECT_TRUE(cmd.HasSwitch("switch2"));
  260. EXPECT_EQ(cmd.GetSwitchValue("switch2", 0), "\"");
  261. }
  262. // Verify things can "work the previous way" - what if my desired parameter starts and ends with quotes?
  263. // -- You can simply start or end with the token and things will work
  264. TEST_F(CommandLineTests, CommandLineParser_QuoteCommaStartOrEndWithCommaNoSpace_Tokenized)
  265. {
  266. AZ::CommandLine cmd;
  267. const char* argValues[] = {
  268. "programname.exe", " -switch1=\"abc,fde\",", "-switch2", " ,\"cba, edf\""
  269. };
  270. cmd.Parse(4, const_cast<char**>(argValues));
  271. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  272. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "\"abc");
  273. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), "fde\"");
  274. EXPECT_TRUE(cmd.HasSwitch("switch1"));
  275. EXPECT_EQ(cmd.GetSwitchValue("switch1", 0), "\"abc");
  276. EXPECT_EQ(cmd.GetSwitchValue("switch1", 1), "fde\"");
  277. EXPECT_TRUE(cmd.HasSwitch("switch2"));
  278. EXPECT_EQ(cmd.GetSwitchValue("switch2", 0), "\"cba");
  279. EXPECT_EQ(cmd.GetSwitchValue("switch2", 1), "edf\"");
  280. }
  281. TEST_F(CommandLineTests, CommandLineParser_DumpingCommandLineAndParsingAgain_ResultsInEquivalentCommandLine)
  282. {
  283. AZ::CommandLine origCommandLine{ AZ::Settings::CommandLineOptionPrefixArray{ "-", "/" } };
  284. const char* argValues[] =
  285. {
  286. "programname.exe", "/gamefolder", "/RemoteIp", "10.0.0.1", "-ScanFolders", R"(\a\b\c,\d\e\f)", "Foo", "Bat"
  287. };
  288. origCommandLine.Parse(aznumeric_cast<int>(AZStd::size(argValues)), const_cast<char**>(AZStd::data(argValues)));
  289. AZ::CommandLine::ParamContainer dumpedCommandLine;
  290. origCommandLine.Dump(dumpedCommandLine);
  291. AZ::CommandLine newCommandLine{ AZ::Settings::CommandLineOptionPrefixArray{ "-", "/" } };
  292. newCommandLine.Parse(dumpedCommandLine);
  293. AZStd::initializer_list<AZ::CommandLine> commandLines{ origCommandLine, newCommandLine };
  294. for (const auto& commandLine : commandLines)
  295. {
  296. EXPECT_TRUE(commandLine.HasSwitch("gamefolder"));
  297. EXPECT_EQ(1, commandLine.GetNumSwitchValues("gamefolder"));
  298. EXPECT_STREQ("", commandLine.GetSwitchValue("gamefolder", 0).c_str());
  299. EXPECT_TRUE(commandLine.HasSwitch("remoteip"));
  300. EXPECT_EQ(1, commandLine.GetNumSwitchValues("remoteip"));
  301. EXPECT_STREQ("10.0.0.1", commandLine.GetSwitchValue("remoteip", 0).c_str());
  302. EXPECT_TRUE(commandLine.HasSwitch("scanfolders"));
  303. EXPECT_EQ(2, commandLine.GetNumSwitchValues("scanfolders"));
  304. EXPECT_STREQ(R"(\a\b\c)", commandLine.GetSwitchValue("scanfolders", 0).c_str());
  305. EXPECT_STREQ(R"(\d\e\f)", commandLine.GetSwitchValue("scanfolders", 1).c_str());
  306. EXPECT_EQ(2, commandLine.GetNumMiscValues());
  307. EXPECT_STREQ("Foo", commandLine.GetMiscValue(0).c_str());
  308. EXPECT_STREQ("Bat", commandLine.GetMiscValue(1).c_str());
  309. }
  310. }
  311. TEST_F(CommandLineTests, CommandLineParser_GetSwitchValue_WithNoArgument_ReturnsLastValue)
  312. {
  313. AZ::CommandLine commandLine{ AZ::Settings::CommandLineOptionPrefixArray{ "--", "-" } };
  314. constexpr AZStd::string_view argValues[] =
  315. {
  316. "programname.exe", "--foo=1", "--foo", "2"
  317. };
  318. commandLine.Parse(argValues);
  319. ASSERT_GE(commandLine.GetNumSwitchValues("foo"), 2);
  320. EXPECT_STREQ("2", commandLine.GetSwitchValue("foo").c_str());
  321. EXPECT_STREQ("2", commandLine.GetSwitchValue("foo", 1).c_str());
  322. EXPECT_STREQ("1", commandLine.GetSwitchValue("foo", 0).c_str());
  323. }
  324. TEST_F(CommandLineTests, ArgumentsParsed_AfterDoubleDash_ArePositionalArgumentsOnly)
  325. {
  326. AZ::CommandLine commandLine{ AZ::Settings::CommandLineOptionPrefixArray{ "--", "-" } };
  327. constexpr AZStd::string_view argValues[] =
  328. {
  329. "programname.exe", "--foo=1", "--", "--foo=2", "bar", "--", "baz"
  330. };
  331. commandLine.Parse(argValues);
  332. EXPECT_EQ(commandLine.GetNumSwitchValues("foo"), 1);
  333. EXPECT_EQ("1", commandLine.GetSwitchValue("foo"));
  334. ASSERT_EQ(5, commandLine.GetNumMiscValues());
  335. // The first Misc entry is the executable name "programname.exe"
  336. // ignore checking that entry since it is not relevant to this test
  337. EXPECT_EQ("--foo=2",commandLine.GetMiscValue(1));
  338. EXPECT_EQ("bar", commandLine.GetMiscValue(2));
  339. EXPECT_EQ("--", commandLine.GetMiscValue(3));
  340. EXPECT_EQ("baz", commandLine.GetMiscValue(4));
  341. }
  342. class CommandLineParserTests
  343. : public LeakDetectionFixture
  344. {
  345. };
  346. TEST_F(CommandLineParserTests, CanParseAllTokensAfterOptionAsValue)
  347. {
  348. AZ::Settings::CommandLineParserSettings parserSettings;
  349. struct Argument
  350. {
  351. AZStd::string m_option;
  352. AZStd::string m_value;
  353. };
  354. AZStd::vector<Argument> parsedArguments;
  355. parserSettings.m_parseCommandLineEntryFunc = [&parsedArguments](const AZ::Settings::CommandLineArgument& argument)
  356. {
  357. parsedArguments.push_back(Argument{ argument.m_option, argument.m_value });
  358. return true;
  359. };
  360. constexpr AZStd::string_view argValues[] =
  361. {
  362. "programname.exe", "--foo=1", "--", "--foo=2", "bar", "--", "baz"
  363. };
  364. auto parseOutcome = AZ::Settings::ParseCommandLine(argValues, parserSettings);
  365. EXPECT_TRUE(parseOutcome);
  366. ASSERT_EQ(6, parsedArguments.size());
  367. EXPECT_TRUE(parsedArguments[0].m_option.empty());
  368. EXPECT_EQ("programname.exe", parsedArguments[0].m_value);
  369. EXPECT_EQ("foo", parsedArguments[1].m_option);
  370. EXPECT_EQ("1", parsedArguments[1].m_value);
  371. EXPECT_TRUE(parsedArguments[2].m_option.empty());
  372. EXPECT_EQ("--foo=2", parsedArguments[2].m_value);
  373. EXPECT_TRUE(parsedArguments[3].m_option.empty());
  374. EXPECT_EQ("bar", parsedArguments[3].m_value);
  375. EXPECT_TRUE(parsedArguments[4].m_option.empty());
  376. EXPECT_EQ("--", parsedArguments[4].m_value);
  377. EXPECT_TRUE(parsedArguments[5].m_option.empty());
  378. EXPECT_EQ("baz", parsedArguments[5].m_value);
  379. }
  380. } // namespace UnitTest