checks.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Pilz GmbH & Co. KG
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHECKS_H
18 #define CHECKS_H
19 
20 #include <gtest/gtest.h>
22 
24 {
25 
26 ::testing::AssertionResult isAtExpectedPosition(const robot_state::RobotState& expected,
27  const robot_state::RobotState& actual,
28  const double epsilon)
29 {
30  if(expected.getVariableCount() != actual.getVariableCount())
31  {
32  return ::testing::AssertionFailure() << "Both states have different number of Variables";
33  }
34 
35  for(size_t i = 0; i < actual.getVariableCount(); ++i)
36  {
37  // PLEASE NOTE: This comparision only works for reasonably
38  // values. That means: Values are not to large, values are
39  // reasonably close by each other.
40  if (std::fabs(expected.getVariablePosition(i) - actual.getVariablePosition(i)) > epsilon)
41  {
42  std::stringstream msg;
43  msg << expected.getVariableNames().at(i) << " position - expected: "
44  << expected.getVariablePosition(i) << " actual: " << actual.getVariablePosition(i);
45 
46  return ::testing::AssertionFailure() << msg.str();
47  }
48  }
49 
50  return ::testing::AssertionSuccess();
51 }
52 
53 }
54 
55 #endif // CENTERAUXILIARY_H
::testing::AssertionResult isAtExpectedPosition(const robot_state::RobotState &expected, const robot_state::RobotState &actual, const double epsilon)
Definition: checks.h:26


pilz_industrial_motion_testutils
Author(s):
autogenerated on Mon Apr 6 2020 03:17:28