test
realtime_buffer_tests.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019, Open Source Robotics Foundation, Inc.
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
*
8
* * Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* * Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* * Neither the name of the Willow Garage, Inc. nor the names of its
14
* contributors may be used to endorse or promote products derived from
15
* this software without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
* POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
#include <gmock/gmock.h>
31
#include <
realtime_tools/realtime_buffer.h
>
32
33
using
realtime_tools::RealtimeBuffer
;
34
35
class
DefaultConstructable
36
{
37
public
:
38
DefaultConstructable
() :
number_
(42) {};
39
~DefaultConstructable
() {};
40
int
number_
;
41
};
42
43
TEST
(
RealtimeBuffer
, default_construct)
44
{
45
RealtimeBuffer<DefaultConstructable>
buffer;
46
EXPECT_EQ(42, buffer.
readFromRT
()->
number_
);
47
}
48
49
TEST
(
RealtimeBuffer
, initial_value)
50
{
51
RealtimeBuffer<double>
buffer(3.14);
52
EXPECT_DOUBLE_EQ(3.14, *buffer.
readFromRT
());
53
}
54
55
TEST
(
RealtimeBuffer
, copy_construct)
56
{
57
const
RealtimeBuffer<char>
buffer(
'a'
);
58
RealtimeBuffer<char>
buffer_copy(buffer);
59
EXPECT_EQ(
'a'
, *buffer_copy.
readFromRT
());
60
}
61
62
TEST
(
RealtimeBuffer
, assignment_operator)
63
{
64
const
RealtimeBuffer<char>
buffer(
'a'
);
65
RealtimeBuffer<char>
buffer2(
'z'
);
66
67
EXPECT_EQ(
'z'
, *buffer2.
readFromRT
());
68
buffer2 = buffer;
69
EXPECT_EQ(
'a'
, *buffer2.
readFromRT
());
70
}
71
72
TEST
(
RealtimeBuffer
, write_read_non_rt)
73
{
74
RealtimeBuffer<int>
buffer(42);
75
76
buffer.
writeFromNonRT
(28);
77
EXPECT_EQ(28, *buffer.
readFromNonRT
());
78
}
79
80
TEST
(
RealtimeBuffer
, initRT)
81
{
82
RealtimeBuffer<int>
buffer(42);
83
buffer.
initRT
(28);
84
EXPECT_EQ(28, *buffer.
readFromRT
());
85
}
realtime_tools::RealtimeBuffer
Definition:
realtime_buffer.h:50
realtime_tools::RealtimeBuffer::writeFromNonRT
void writeFromNonRT(const T &data)
Definition:
realtime_buffer.h:132
TEST
TEST(RealtimeBuffer, default_construct)
Definition:
realtime_buffer_tests.cpp:43
DefaultConstructable::DefaultConstructable
DefaultConstructable()
Definition:
realtime_buffer_tests.cpp:38
realtime_tools::RealtimeBuffer::readFromNonRT
T * readFromNonRT() const
Definition:
realtime_buffer.h:122
realtime_tools::RealtimeBuffer::readFromRT
T * readFromRT()
Definition:
realtime_buffer.h:104
DefaultConstructable
Definition:
realtime_box_tests.cpp:35
realtime_buffer.h
DefaultConstructable::number_
int number_
Definition:
realtime_box_tests.cpp:39
DefaultConstructable::~DefaultConstructable
~DefaultConstructable()
Definition:
realtime_buffer_tests.cpp:39
realtime_tools::RealtimeBuffer::initRT
void initRT(const T &data)
Definition:
realtime_buffer.h:149
realtime_tools
Author(s): Stuart Glaser
autogenerated on Mon Jan 8 2024 03:20:12