TEST(ArgsTest, AppendArguments) { Args args; const char *argv[] = {"1", "2", nullptr}; const char *argv2[] = {"3", "4", nullptr}; args.AppendArguments(argv); ASSERT_EQ(2u, args.GetArgumentCount()); EXPECT_STREQ("1", args.GetArgumentVector()[0]); EXPECT_STREQ("2", args.GetArgumentVector()[1]); EXPECT_EQ(nullptr, args.GetArgumentVector()[2]); EXPECT_STREQ("1", args.GetArgumentAtIndex(0)); EXPECT_STREQ("2", args.GetArgumentAtIndex(1)); args.AppendArguments(argv2); ASSERT_EQ(4u, args.GetArgumentCount()); EXPECT_STREQ("1", args.GetArgumentVector()[0]); EXPECT_STREQ("2", args.GetArgumentVector()[1]); EXPECT_STREQ("3", args.GetArgumentVector()[2]); EXPECT_STREQ("4", args.GetArgumentVector()[3]); EXPECT_EQ(nullptr, args.GetArgumentVector()[4]); EXPECT_STREQ("1", args.GetArgumentAtIndex(0)); EXPECT_STREQ("2", args.GetArgumentAtIndex(1)); EXPECT_STREQ("3", args.GetArgumentAtIndex(2)); EXPECT_STREQ("4", args.GetArgumentAtIndex(3)); }
bool DoExecute(Args &command, CommandReturnObject &result) override { SBCommandReturnObject sb_return(&result); SBCommandInterpreter sb_interpreter(&m_interpreter); SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this()); bool ret = m_backend->DoExecute( debugger_sb, (char **)command.GetArgumentVector(), sb_return); sb_return.Release(); return ret; }
TEST(ArgsTest, TestArgv) { Args args; EXPECT_EQ(nullptr, args.GetArgumentVector()); args.AppendArgument("1"); EXPECT_NE(nullptr, args.GetArgumentVector()[0]); EXPECT_EQ(nullptr, args.GetArgumentVector()[1]); args.AppendArgument("2"); EXPECT_NE(nullptr, args.GetArgumentVector()[0]); EXPECT_NE(nullptr, args.GetArgumentVector()[1]); EXPECT_EQ(nullptr, args.GetArgumentVector()[2]); args.AppendArgument("3"); EXPECT_NE(nullptr, args.GetArgumentVector()[0]); EXPECT_NE(nullptr, args.GetArgumentVector()[1]); EXPECT_NE(nullptr, args.GetArgumentVector()[2]); EXPECT_EQ(nullptr, args.GetArgumentVector()[3]); args.InsertArgumentAtIndex(1, "1.5"); EXPECT_NE(nullptr, args.GetArgumentVector()[0]); EXPECT_NE(nullptr, args.GetArgumentVector()[1]); EXPECT_NE(nullptr, args.GetArgumentVector()[2]); EXPECT_NE(nullptr, args.GetArgumentVector()[3]); EXPECT_EQ(nullptr, args.GetArgumentVector()[4]); args.InsertArgumentAtIndex(4, "3.5"); EXPECT_NE(nullptr, args.GetArgumentVector()[0]); EXPECT_NE(nullptr, args.GetArgumentVector()[1]); EXPECT_NE(nullptr, args.GetArgumentVector()[2]); EXPECT_NE(nullptr, args.GetArgumentVector()[3]); EXPECT_NE(nullptr, args.GetArgumentVector()[4]); EXPECT_EQ(nullptr, args.GetArgumentVector()[5]); }