Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
VABase
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
VABase
Commits
7f679831
Commit
7f679831
authored
Oct 15, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating tests to new API
parent
f26607f7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
30 deletions
+44
-30
tests/ObjectTest.cpp
tests/ObjectTest.cpp
+44
-30
No files found.
tests/ObjectTest.cpp
View file @
7f679831
...
...
@@ -7,87 +7,101 @@
using
namespace
std
;
class
TestObject
:
public
CVAObject
{
class
TestObject
:
public
CVAObject
{
public:
TestObject
()
:
CVAObject
(
"TestObject"
)
{
inline
TestObject
()
:
CVAObject
(
"TestObject"
)
{
};
}
inline
CVAStruct
CallObject
(
const
CVAStruct
&
)
{
return
CVAStruct
();
};
int
HandleMessage
(
const
CVAStruct
*
pArgumentMessage
,
CVAStruct
*
pReturnMessage
)
{
inline
int
HandleMessage
(
const
CVAStruct
*
pArgumentMessage
,
CVAStruct
*
pReturnMessage
)
{
// No arguments => Do nothing
if
(
!
pArgumentMessage
)
return
0
;
if
(
!
pArgumentMessage
)
return
0
;
const
CVAStructValue
*
pCommand
=
pArgumentMessage
->
GetValue
(
"command"
);
const
CVAStructValue
*
pCommand
=
pArgumentMessage
->
GetValue
(
"command"
);
// No command => Do nothing
if
(
!
pCommand
)
return
0
;
if
(
!
pCommand
)
return
0
;
// Command must be a string
if
(
!
pCommand
->
IsString
())
return
-
1
;
if
(
!
pCommand
->
IsString
()
)
return
-
1
;
std
::
string
sCommand
=
*
pCommand
;
for
(
auto
&
c
:
sCommand
)
c
=
toupper
(
c
);
for
(
auto
&
c
:
sCommand
)
c
=
char
(
toupper
(
c
)
);
if
(
sCommand
==
"SAYHELLO"
)
{
if
(
sCommand
==
"SAYHELLO"
)
{
cout
<<
"Object
\"
"
<<
GetObjectName
()
<<
"
\"
says hello!"
<<
endl
;
// No return values
return
0
;
}
if
(
sCommand
==
"PRINTID"
)
{
if
(
sCommand
==
"PRINTID"
)
{
cout
<<
"Object
\"
"
<<
GetObjectName
()
<<
"
\"
has ID "
<<
GetObjectID
()
<<
endl
;
// No return values
return
0
;
}
if
(
sCommand
==
"TEST"
)
{
if
(
sCommand
==
"TEST"
)
{
cout
<<
"Object
\"
"
<<
GetObjectName
()
<<
"
\"
was called >test< "
<<
endl
;
pReturnMessage
->
Clear
();
(
*
pReturnMessage
)[
"Number"
]
=
4711
;
(
*
pReturnMessage
)[
"Number"
]
=
4711
;
return
pReturnMessage
->
Size
();
}
// Invalid command
return
-
1
;
}
}
;
};
int
main
()
{
try
{
int
main
(
int
,
char
**
)
{
try
{
CVAObjectRegistry
reg
;
TestObject
obj
;
reg
.
RegisterObject
(
&
obj
);
reg
.
RegisterObject
(
&
obj
);
cout
<<
"Test object registered. Got ID "
<<
obj
.
GetObjectID
()
<<
endl
;
// Search for object
CVAObject
*
pObj
=
reg
.
GetObjectByName
(
"TestObject"
);
CVAObject
*
pObj
=
reg
.
GetObjectByName
(
"TestObject"
);
cout
<<
pObj
<<
endl
;
CVAStruct
in
,
out
;
int
result
;
in
[
"command"
]
=
"SayHello"
;
result
=
obj
.
HandleMessage
(
&
in
,
&
out
);
in
[
"command"
]
=
"SayHello"
;
result
=
obj
.
HandleMessage
(
&
in
,
&
out
);
cout
<<
"Result = "
<<
result
<<
endl
;
if
(
result
!=
0
)
if
(
result
!=
0
)
cout
<<
"Return message = "
<<
out
<<
endl
;
in
[
"command"
]
=
"PrintID"
;
result
=
obj
.
HandleMessage
(
&
in
,
&
out
);
in
[
"command"
]
=
"PrintID"
;
result
=
obj
.
HandleMessage
(
&
in
,
&
out
);
cout
<<
"Result = "
<<
result
<<
endl
;
if
(
result
!=
0
)
if
(
result
!=
0
)
cout
<<
"Return message = "
<<
out
<<
endl
;
in
[
"command"
]
=
"Test"
;
result
=
obj
.
HandleMessage
(
&
in
,
&
out
);
in
[
"command"
]
=
"Test"
;
result
=
obj
.
HandleMessage
(
&
in
,
&
out
);
cout
<<
"Result = "
<<
result
<<
endl
;
if
(
result
!=
0
)
if
(
result
!=
0
)
cout
<<
"Return message = "
<<
out
<<
endl
;
}
catch
(
CVAException
&
e
)
{
}
catch
(
CVAException
&
e
)
{
cerr
<<
"Error: "
<<
e
<<
endl
;
return
e
.
GetErrorCode
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment