Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic-graph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
dynamic-graph
Commits
24fe1bed
Commit
24fe1bed
authored
14 years ago
by
Thomas Moulard
Browse files
Options
Downloads
Patches
Plain Diff
Clean interpreter test.
parent
aea8cd1c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/interpreter.cpp
+28
-58
28 additions, 58 deletions
tests/interpreter.cpp
with
28 additions
and
58 deletions
tests/interpreter.cpp
+
28
−
58
View file @
24fe1bed
...
...
@@ -31,6 +31,22 @@ using boost::test_tools::output_test_stream;
// becomes too big.
#define RUN_COMMAND(CMD, ARGS) \
output_test_stream output; \
std::stringstream ss; \
std::string cmd = CMD; \
ss << ARGS; \
std::istringstream args (ss.str ()); \
shell.cmd (cmd, args, output)
#define RUN_COMMAND_NOARG(CMD) \
output_test_stream output; \
std::stringstream ss; \
std::string cmd = CMD; \
std::istringstream args (ss.str ()); \
shell.cmd (cmd, args, output)
// Simple test to check the shell default constructor.
BOOST_AUTO_TEST_CASE
(
constructor
)
{
...
...
@@ -41,10 +57,8 @@ BOOST_AUTO_TEST_CASE (constructor)
// Check that an empty command is valid.
BOOST_AUTO_TEST_CASE
(
cmd_empty
)
{
output_test_stream
output
;
std
::
istringstream
args
;
dynamicgraph
::
Interpreter
shell
;
shell
.
cmd
(
""
,
args
,
output
);
RUN_COMMAND_NOARG
(
""
);
BOOST_CHECK
(
output
.
is_empty
());
}
...
...
@@ -53,12 +67,10 @@ BOOST_AUTO_TEST_CASE (cmd_empty)
// the appropriate error.
BOOST_AUTO_TEST_CASE
(
cmd_notexist
)
{
output_test_stream
output
;
std
::
istringstream
args
;
dynamicgraph
::
Interpreter
shell
;
try
{
shell
.
cmd
(
"I DO NOT EXIST"
,
args
,
output
);
RUN_COMMAND_NOARG
(
"I DO NOT EXIST"
);
}
catch
(
const
dynamicgraph
::
ExceptionFactory
&
exception
)
{
...
...
@@ -71,10 +83,10 @@ BOOST_AUTO_TEST_CASE (cmd_notexist)
// Check that the "help" command works.
BOOST_AUTO_TEST_CASE
(
cmd_help
)
{
output_test_stream
output
;
std
::
istringstream
args
;
dynamicgraph
::
Interpreter
shell
;
shell
.
cmd
(
"help"
,
args
,
output
);
RUN_COMMAND_NOARG
(
"help"
);
BOOST_CHECK
(
output
.
is_equal
(
...
...
@@ -99,16 +111,8 @@ BOOST_AUTO_TEST_CASE (cmd_help)
// Check that an empty file can be parsed successfully.
BOOST_AUTO_TEST_CASE
(
cmd_run_emptyfile
)
{
output_test_stream
output
;
dynamicgraph
::
Interpreter
shell
;
std
::
stringstream
ss
;
std
::
string
cmd
=
"run"
;
ss
<<
TESTS_DATADIR
"/empty.sot"
;
std
::
istringstream
args
(
ss
.
str
());
shell
.
cmd
(
cmd
,
args
,
output
);
RUN_COMMAND
(
"run"
,
TESTS_DATADIR
"/empty.sot"
);
BOOST_CHECK
(
output
.
is_empty
());
}
...
...
@@ -116,18 +120,11 @@ BOOST_AUTO_TEST_CASE (cmd_run_emptyfile)
// error.
BOOST_AUTO_TEST_CASE
(
cmd_run_notexist
)
{
output_test_stream
output
;
dynamicgraph
::
Interpreter
shell
;
std
::
stringstream
ss
;
std
::
string
cmd
=
"run"
;
ss
<<
"idonotexist"
;
std
::
istringstream
args
(
ss
.
str
());
try
{
shell
.
cmd
(
cmd
,
args
,
output
);
RUN_COMMAND
(
"run"
,
"idonotexist"
);
BOOST_ERROR
(
"Should never happen"
);
}
catch
(
const
dynamicgraph
::
ExceptionFactory
&
exception
)
...
...
@@ -140,18 +137,10 @@ BOOST_AUTO_TEST_CASE (cmd_run_notexist)
// Check that import a non existing file returns an appropriate error.
BOOST_AUTO_TEST_CASE
(
cmd_import_notexist
)
{
output_test_stream
output
;
dynamicgraph
::
Interpreter
shell
;
std
::
stringstream
ss
;
std
::
string
cmd
=
"import"
;
ss
<<
"idonotexist"
;
std
::
istringstream
args
(
ss
.
str
());
try
{
shell
.
cmd
(
cmd
,
args
,
output
);
RUN_COMMAND
(
"import"
,
"idonotexist"
);
BOOST_ERROR
(
"Should never happen"
);
}
catch
(
const
dynamicgraph
::
ExceptionFactory
&
exception
)
...
...
@@ -168,36 +157,19 @@ BOOST_AUTO_TEST_CASE (cmd_import_push)
// Push path.
{
output_test_stream
output
;
std
::
stringstream
ss
;
std
::
string
cmd
=
"pushImportPaths"
;
ss
<<
TESTS_DATADIR
;
std
::
istringstream
args
(
ss
.
str
());
shell
.
cmd
(
cmd
,
args
,
output
);
RUN_COMMAND
(
"pushImportPaths"
,
TESTS_DATADIR
);
BOOST_CHECK
(
output
.
is_empty
());
}
// Import empty file.
{
output_test_stream
output
;
std
::
stringstream
ss
;
std
::
string
cmd
=
"import"
;
ss
<<
"empty.sot"
;
std
::
istringstream
args
(
ss
.
str
());
shell
.
cmd
(
cmd
,
args
,
output
);
RUN_COMMAND
(
"import"
,
"empty.sot"
);
BOOST_CHECK
(
output
.
is_empty
());
}
// Pop path.
{
output_test_stream
output
;
std
::
stringstream
ss
;
std
::
string
cmd
=
"popImportPaths"
;
std
::
istringstream
args
(
ss
.
str
());
shell
.
cmd
(
cmd
,
args
,
output
);
RUN_COMMAND_NOARG
(
"popImportPaths"
);
BOOST_CHECK
(
output
.
is_empty
());
}
...
...
@@ -206,13 +178,11 @@ BOOST_AUTO_TEST_CASE (cmd_import_push)
{
output_test_stream
output
;
std
::
stringstream
ss
;
std
::
string
cmd
=
"import"
;
ss
<<
"empty.sot"
;
std
::
istringstream
args
(
ss
.
str
());
// Make sure this trigger an error.
BOOST_CHECK_THROW
(
shell
.
cmd
(
cmd
,
args
,
output
),
BOOST_CHECK_THROW
(
shell
.
cmd
(
"import"
,
args
,
output
),
dynamicgraph
::
ExceptionFactory
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment