Skip to content

Commit

Permalink
Adding some testing
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Wagner <[email protected]>
  • Loading branch information
WagnerMarcos committed Jun 29, 2021
1 parent 4e24940 commit f4e5cdd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 13 deletions.
62 changes: 52 additions & 10 deletions model/src/ModelCommandAPI_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST(ModelCommandAPI, Commands)
{
ignition::gazebo::ServerConfig serverConfig;
serverConfig.SetSdfFile(std::string(PROJECT_SOURCE_PATH) +
"/test/worlds/shapes.sdf");
"/examples/worlds/shapes.sdf");

ignition::gazebo::Server server(serverConfig);
// Run at least one iteration before continuing to guarantee correctly set up.
Expand All @@ -81,6 +81,7 @@ TEST(ModelCommandAPI, Commands)
const std::string output = customExecStr(cmd);
const std::string expectedOutput =
"Available models:\n"
" - ground_plane\n"
" - box\n"
" - cylinder\n"
" - sphere\n";
Expand All @@ -89,23 +90,64 @@ TEST(ModelCommandAPI, Commands)

// Tested command: ign model -m cylinder
{
// const std::string cmd = kIgnModelCommand + "-m cylinder";
// const std::string output = customExecStr(cmd);
const std::string cmd = kIgnModelCommand + "-m box";
const std::string output = customExecStr(cmd);
const std::string expectedOutput =

"\nRequesting state for world [shapes] on service [/world/shapes/state]...\n\n"
"Name: box\n"
" - Pose: \n"
" [0.000000 | -0.000000 | 0.500000]\n"
" [0.000000 | 0.000000 | 0.000000]\n\n"
" - Link [9]\n"
" - Name: box_link\n"
" - Parent: box [8]\n"
" - Mass: [1.000000]\n"
" - Inertial Matrix: \n"
" [1.000000 | 0.000000 | 0.000000]\n"
" [0.000000 | 1.000000 | 0.000000]\n"
" [0.000000 | 0.000000 | 1.000000]\n"
" - Pose: \n"
" [0.000000 | 0.000000 | 0.000000]\n"
" [0.000000 | -0.000000 | 0.000000]\n";

// TODO(@wagnermarcos): Implement test.
EXPECT_EQ(expectedOutput, output);
}

// Tested command: ign model -m cylinder --pose
// Tested command: ign model -m vehicle_blue --pose
{
// const std::string cmd = kIgnModelCommand + "-m cylinder --pose ";
// const std::string output = customExecStr(cmd);
const std::string cmd = kIgnModelCommand + "-m box --pose ";
const std::string output = customExecStr(cmd);
const std::string expectedOutput =
"\nRequesting state for world [shapes] on service [/world/shapes/state]...\n\n"
"Name: box\n"
" - Pose: \n"
" [0.000000 | -0.000000 | 0.500000]\n"
" [0.000000 | 0.000000 | 0.000000]\n\n";
EXPECT_EQ(expectedOutput, output);
// TODO(@wagnermarcos): Implement test.
}

// Tested command: ign model -m cylinder --link cylinder_link
// Tested command: ign model -m box --link box_link
{
// const std::string cmd = kIgnModelCommand +
// "-m cylinder --link cylinder_link";
// const std::string output = customExecStr(cmd);
const std::string cmd = kIgnModelCommand +
"-m box --link box_link";
const std::string output = customExecStr(cmd);
const std::string expectedOutput =
"\nRequesting state for world [shapes] on service [/world/shapes/state]...\n\n"
" - Link [9]\n"
" - Name: box_link\n"
" - Parent: box [8]\n"
" - Mass: [1.000000]\n"
" - Inertial Matrix: \n"
" [1.000000 | 0.000000 | 0.000000]\n"
" [0.000000 | 1.000000 | 0.000000]\n"
" [0.000000 | 0.000000 | 1.000000]\n"
" - Pose: \n"
" [0.000000 | 0.000000 | 0.000000]\n"
" [0.000000 | -0.000000 | 0.000000]\n";
EXPECT_EQ(expectedOutput, output);
// TODO(@wagnermarcos): Implement test.
}
}
Expand Down
10 changes: 7 additions & 3 deletions model/src/cmd/cmdmodel.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ COMMON_OPTIONS =

COMMANDS = { 'model' =>
"Print information about models.\n\n"+
" --list Get a list of the available models. \n"\
" -m [--model] [model_name] Select the model to shown. \n\n"+
" --list Get a list of the available models. \n"\
" -m [--model] [model_name] Select the model to be shown. \n"\
" -l [--link] [link_name] Select a link to show it's properties. \n"\
" -j [--joint] [joint_name] Select a joint to show it's properties. \n\n"\
" E.g. to get information about the \n"\
" box_link in the shapes world, run: \n"\
" ign model -m box -l box_link \n\n"+
COMMON_OPTIONS
}

Expand Down Expand Up @@ -95,7 +100,6 @@ class Cmd
end

options['command'] = args[0]
# options['subcommand'] = args[1]

options
end # parse()
Expand Down

0 comments on commit f4e5cdd

Please sign in to comment.