unit_tests.cpp
Go to the documentation of this file.
1 /***
2  * Software License Agreement: BSD 3-Clause License
3  *
4  * Copyright (c) 2016-2018, qbrobotics®
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
8  * following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
11  * following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
14  * following disclaimer in the documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
17  * products derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 // Google Testing Framework
29 #include <gtest/gtest.h>
30 //#include <gmock/gmock.h>
31 // qb robotics libraries
33 
34 TEST(Resources, Constructors) {
35  // positive tests
37  EXPECT_EQ(1, default_constructor.id);
38  EXPECT_EQ(+1, default_constructor.motor_axis_direction);
39 
40  std::vector<int> right_ids = {0, 1, -1, 255, -255};
41  for (auto const id : right_ids) {
43  EXPECT_EQ(std::abs(id), constructor.id);
44  if (id > 0) {
45  EXPECT_EQ(+1, constructor.motor_axis_direction);
46  } else if (id < 0) {
47  EXPECT_EQ(-1, constructor.motor_axis_direction);
48  } else {
49  EXPECT_EQ(0, constructor.motor_axis_direction); // zero is the broadcast id (i.e. no motor is controlled)
50  }
51  }
52 
53  // negative tests
54  std::vector<int> wrong_ids = {256, -256};
55  for (auto const id : wrong_ids) {
57  //FIXME
58  }
59 }
60 
61 
62 int main(int argc, char **argv) {
63  testing::InitGoogleTest(&argc, argv);
64 // testing::InitGoogleMock(&argc, argv);
65 // testing::FLAGS_gmock_verbose = "info";
66  ros::init(argc, argv, "unit_tests");
67  return RUN_ALL_TESTS();
68 }
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
Definition: unit_tests.cpp:62
TEST(Resources, Constructors)
Definition: unit_tests.cpp:34
The qbrobotics Device Resources contains just few device information.


qb_device_hardware_interface
Author(s): qbrobotics®
autogenerated on Thu Jun 6 2019 19:46:29