test_rtde_control_package_start.cpp
Go to the documentation of this file.
1 // -- BEGIN LICENSE BLOCK ----------------------------------------------
2 // Copyright 2022 Universal Robots A/S
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //
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 //
14 // * Neither the name of the {copyright_holder} nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 // POSSIBILITY OF SUCH DAMAGE.
29 // -- END LICENSE BLOCK ------------------------------------------------
30 
31 #include <gtest/gtest.h>
33 
34 using namespace urcl;
35 
36 TEST(rtde_control_package_start, generate_serialized_start_request)
37 {
38  uint8_t buffer[4096];
39  size_t expected_size = 3;
41 
42  EXPECT_EQ(expected_size, actual_size);
43 
44  uint8_t expected[] = { 0x00, 0x03, 0x53 };
45  for (unsigned int i = 0; i < actual_size; ++i)
46  {
47  EXPECT_EQ(expected[i], buffer[i]);
48  }
49 }
50 
51 TEST(rtde_control_package_start, parse_accepted_start_request)
52 {
54 
55  uint8_t start_answer[] = { 0x01 };
56  comm::BinParser bp(start_answer, sizeof(start_answer));
57 
58  EXPECT_TRUE(start_package.parseWith(bp));
59 
60  uint8_t expected_answer = 1;
61  uint8_t actual_answer = start_package.accepted_;
62 
63  EXPECT_EQ(expected_answer, actual_answer);
64 }
65 
66 TEST(rtde_control_package_start, parse_not_accepted_start_request)
67 {
69 
70  uint8_t start_answer[] = { 0x00 };
71  comm::BinParser bp(start_answer, sizeof(start_answer));
72 
73  EXPECT_TRUE(start_package.parseWith(bp));
74 
75  uint8_t expected_answer = 0;
76  uint8_t actual_answer = start_package.accepted_;
77 
78  EXPECT_EQ(expected_answer, actual_answer);
79 }
80 
81 int main(int argc, char* argv[])
82 {
83  ::testing::InitGoogleTest(&argc, argv);
84 
85  return RUN_ALL_TESTS();
86 }
int main(int argc, char *argv[])
This class handles the robot&#39;s response to a requested start in RTDE data package communication...
The BinParser class handles a byte buffer and functionality to iteratively parse the content...
Definition: bin_parser.h:44
TEST(rtde_control_package_start, generate_serialized_start_request)
static size_t generateSerializedRequest(uint8_t *buffer)
Generates a serialized package.
virtual bool parseWith(comm::BinParser &bp)
Sets the attributes of the package by parsing a serialized representation of the package.


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Tue Jul 4 2023 02:09:47