Main Page
Namespaces
Namespace List
Namespace Members
All
Functions
Variables
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
g
h
i
l
m
n
p
r
s
t
v
Functions
_
a
c
d
g
i
l
m
n
p
r
s
v
Variables
a
b
c
d
e
h
i
l
m
n
p
r
s
t
v
Typedefs
Files
File List
File Members
All
Functions
Variables
test
subscriber_test.cpp
Go to the documentation of this file.
1
#include "ros/subscriber.h"
2
#include <gtest/gtest.h>
3
4
5
bool
callbackCalled
;
6
unsigned
char
buffer
[1];
7
8
class
DummyMsg
9
{
10
public
:
11
int
serialize
(
unsigned
char
*outbuffer)
const
12
{
13
return
0;
14
}
15
int
deserialize
(
unsigned
char
*inbuffer)
16
{
17
return
0;
18
}
19
const
char
*
getType
()
20
{
21
return
""
;
22
}
23
const
char
*
getMD5
()
24
{
25
return
""
;
26
}
27
};
28
29
class
DummyClass
30
{
31
public
:
32
static
void
staticCallback
(
const
DummyMsg
& msg)
33
{
34
callbackCalled
=
true
;
35
}
36
void
memberCallback
(
const
DummyMsg
& msg)
37
{
38
callbackCalled
=
true
;
39
}
40
};
41
42
43
TEST
(TestSubscriber, testStaticCallback)
44
{
45
ros::Subscriber<DummyMsg>
sub(
"topic_name"
, &
DummyClass::staticCallback
);
46
47
callbackCalled
=
false
;
48
sub.callback(
buffer
);
49
ASSERT_TRUE(
callbackCalled
);
50
}
51
52
TEST
(TestSubscriber, testMemberCallback)
53
{
54
DummyClass
cl;
55
ros::Subscriber<DummyMsg, DummyClass>
sub(
"topic_name"
, &
DummyClass::memberCallback
, &cl);
56
57
callbackCalled
=
false
;
58
sub.callback(
buffer
);
59
ASSERT_TRUE(
callbackCalled
);
60
}
61
62
63
int
main
(
int
argc,
char
**argv)
64
{
65
testing::InitGoogleTest(&argc, argv);
66
return
RUN_ALL_TESTS();
67
}
DummyClass
Definition:
subscriber_test.cpp:29
DummyClass::memberCallback
void memberCallback(const DummyMsg &msg)
Definition:
subscriber_test.cpp:36
main
int main(int argc, char **argv)
Definition:
subscriber_test.cpp:63
DummyClass::staticCallback
static void staticCallback(const DummyMsg &msg)
Definition:
subscriber_test.cpp:32
callbackCalled
bool callbackCalled
Definition:
subscriber_test.cpp:5
DummyMsg::serialize
int serialize(unsigned char *outbuffer) const
Definition:
subscriber_test.cpp:11
DummyMsg::deserialize
int deserialize(unsigned char *inbuffer)
Definition:
subscriber_test.cpp:15
DummyMsg::getType
const char * getType()
Definition:
subscriber_test.cpp:19
buffer
unsigned char buffer[1]
Definition:
subscriber_test.cpp:6
DummyMsg
Definition:
subscriber_test.cpp:8
TEST
TEST(TestSubscriber, testStaticCallback)
Definition:
subscriber_test.cpp:43
DummyMsg::getMD5
const char * getMD5()
Definition:
subscriber_test.cpp:23
ros::Subscriber
Definition:
subscriber.h:60
rosserial_client
Author(s): Michael Ferguson, Adam Stambler
autogenerated on Wed Mar 2 2022 00:58:01