[lldb][NFC] Extend ArgsTest

llvm-svn: 371180
This commit is contained in:
Raphael Isemann 2019-09-06 08:39:53 +00:00
parent 312409e464
commit 0d50c4e060
1 changed files with 68 additions and 0 deletions

View File

@ -37,6 +37,34 @@ TEST(ArgsTest, TestSingleArgWithQuotedSpace) {
EXPECT_STREQ(args.GetArgumentAtIndex(0), "arg with space");
}
TEST(ArgsTest, TestTrailingBackslash) {
Args args;
args.SetCommandString("arg\\");
EXPECT_EQ(1u, args.GetArgumentCount());
EXPECT_STREQ(args.GetArgumentAtIndex(0), "arg\\");
}
TEST(ArgsTest, TestQuotedTrailingBackslash) {
Args args;
args.SetCommandString("\"arg\\");
EXPECT_EQ(1u, args.GetArgumentCount());
EXPECT_STREQ(args.GetArgumentAtIndex(0), "arg\\");
}
TEST(ArgsTest, TestUnknownEscape) {
Args args;
args.SetCommandString("arg\\y");
EXPECT_EQ(1u, args.GetArgumentCount());
EXPECT_STREQ(args.GetArgumentAtIndex(0), "arg\\y");
}
TEST(ArgsTest, TestQuotedUnknownEscape) {
Args args;
args.SetCommandString("\"arg\\y");
EXPECT_EQ(1u, args.GetArgumentCount());
EXPECT_STREQ(args.GetArgumentAtIndex(0), "arg\\y");
}
TEST(ArgsTest, TestMultipleArgs) {
Args args;
args.SetCommandString("this has multiple args");
@ -214,3 +242,43 @@ TEST(ArgsTest, EscapeLLDBCommandArgument) {
EXPECT_EQ("quux\t", Args::EscapeLLDBCommandArgument(quux, '`'));
EXPECT_EQ("quux\t", Args::EscapeLLDBCommandArgument(quux, '"'));
}
TEST(ArgsTest, ReplaceArgumentAtIndexShort) {
Args args;
args.SetCommandString("foo ba b");
args.ReplaceArgumentAtIndex(0, "f");
EXPECT_EQ(3u, args.GetArgumentCount());
EXPECT_STREQ(args.GetArgumentAtIndex(0), "f");
}
TEST(ArgsTest, ReplaceArgumentAtIndexEqual) {
Args args;
args.SetCommandString("foo ba b");
args.ReplaceArgumentAtIndex(0, "bar");
EXPECT_EQ(3u, args.GetArgumentCount());
EXPECT_STREQ(args.GetArgumentAtIndex(0), "bar");
}
TEST(ArgsTest, ReplaceArgumentAtIndexLonger) {
Args args;
args.SetCommandString("foo ba b");
args.ReplaceArgumentAtIndex(0, "baar");
EXPECT_EQ(3u, args.GetArgumentCount());
EXPECT_STREQ(args.GetArgumentAtIndex(0), "baar");
}
TEST(ArgsTest, ReplaceArgumentAtIndexOutOfRange) {
Args args;
args.SetCommandString("foo ba b");
args.ReplaceArgumentAtIndex(3, "baar");
EXPECT_EQ(3u, args.GetArgumentCount());
EXPECT_STREQ(args.GetArgumentAtIndex(2), "b");
}
TEST(ArgsTest, ReplaceArgumentAtIndexFarOutOfRange) {
Args args;
args.SetCommandString("foo ba b");
args.ReplaceArgumentAtIndex(4, "baar");
EXPECT_EQ(3u, args.GetArgumentCount());
EXPECT_STREQ(args.GetArgumentAtIndex(2), "b");
}