TEST(ArgsTest, TestOverwriteArgs) { Args args; args.SetCommandString("this has multiple args"); EXPECT_EQ(4u, args.GetArgumentCount()); args.SetCommandString("arg"); EXPECT_EQ(1u, args.GetArgumentCount()); EXPECT_STREQ(args.GetArgumentAtIndex(0), "arg"); }
TEST(ArgsTest, DoubleQuotedItem) { Args args; args.SetCommandString("\"a b c\""); EXPECT_EQ(1u, args.GetArgumentCount()); EXPECT_STREQ("a b c", args.GetArgumentAtIndex(0)); }
TEST(ArgsTest, BareSingleQuote) { Args args; args.SetCommandString("a\\'b"); EXPECT_EQ(1u, args.GetArgumentCount()); EXPECT_STREQ("a'b", args.GetArgumentAtIndex(0)); }
TEST(ArgsTest, TestAppendArg) { Args args; args.SetCommandString("first_arg"); EXPECT_EQ(1u, args.GetArgumentCount()); args.AppendArgument(llvm::StringRef("second_arg")); EXPECT_EQ(2u, args.GetArgumentCount()); EXPECT_STREQ(args.GetArgumentAtIndex(0), "first_arg"); EXPECT_STREQ(args.GetArgumentAtIndex(1), "second_arg"); }
TEST(ArgsTest, TestMultipleArgs) { Args args; args.SetCommandString("this has multiple args"); EXPECT_EQ(4u, args.GetArgumentCount()); EXPECT_STREQ(args.GetArgumentAtIndex(0), "this"); EXPECT_STREQ(args.GetArgumentAtIndex(1), "has"); EXPECT_STREQ(args.GetArgumentAtIndex(2), "multiple"); EXPECT_STREQ(args.GetArgumentAtIndex(3), "args"); }
TEST(ArgsTest, GetQuotedCommandString) { Args args; const char *str = "process launch -o stdout.txt -- \"a b c\""; args.SetCommandString(str); std::string stdstr; ASSERT_TRUE(args.GetQuotedCommandString(stdstr)); EXPECT_EQ(str, stdstr); }
TEST(ArgsTest, TestSingleArgWithQuotedSpace) { Args args; args.SetCommandString("arg\\ with\\ space"); EXPECT_EQ(1u, args.GetArgumentCount()); EXPECT_STREQ(args.GetArgumentAtIndex(0), "arg with space"); }
TEST(ArgsTest, TestSingleArg) { Args args; args.SetCommandString("arg"); EXPECT_EQ(1u, args.GetArgumentCount()); EXPECT_STREQ(args.GetArgumentAtIndex(0), "arg"); }