Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "descartes_core/trajectory_pt.h"
00020 #include "descartes_trajectory/cart_trajectory_pt.h"
00021 #include "descartes_trajectory/joint_trajectory_pt.h"
00022 #include "descartes_trajectory/axial_symmetric_pt.h"
00023 #include "ros/console.h"
00024 #include <gtest/gtest.h>
00025
00026 using namespace descartes_core;
00027 using namespace descartes_trajectory;
00028
00029
00030 bool equal(const descartes_core::TimingConstraint& a, const descartes_core::TimingConstraint& b)
00031 {
00032 return std::abs(a.upper - b.upper) < 0.001;
00033 }
00034
00035
00036 template <class T>
00037 TrajectoryPt* CreateTrajectoryPt();
00038
00039 template <>
00040 TrajectoryPt* CreateTrajectoryPt<CartTrajectoryPt>()
00041 {
00042 return new CartTrajectoryPt();
00043 }
00044
00045 template <>
00046 TrajectoryPt* CreateTrajectoryPt<JointTrajectoryPt>()
00047 {
00048 return new JointTrajectoryPt();
00049 }
00050
00051 template <>
00052 TrajectoryPt* CreateTrajectoryPt<AxialSymmetricPt>()
00053 {
00054 return new AxialSymmetricPt();
00055 }
00056
00057 template <class T>
00058 class TrajectoryPtTest : public testing::Test
00059 {
00060 protected:
00061 TrajectoryPtTest()
00062 : lhs_(CreateTrajectoryPt<T>())
00063 , rhs_(CreateTrajectoryPt<T>())
00064 , lhs_copy_(CreateTrajectoryPt<T>())
00065 , lhs_clone_(CreateTrajectoryPt<T>())
00066 {
00067 lhs_->setTiming(descartes_core::TimingConstraint(10.0));
00068
00069 lhs_copy_ = lhs_->copy();
00070 lhs_clone_ = lhs_->clone();
00071 lhs_same_ = lhs_;
00072 }
00073
00074 TrajectoryPtPtr lhs_;
00075 TrajectoryPtPtr rhs_;
00076 TrajectoryPtPtr lhs_copy_;
00077 TrajectoryPtPtr lhs_clone_;
00078 TrajectoryPtPtr lhs_same_;
00079 };
00080
00081 using testing::Types;
00082
00083
00084 typedef Types<CartTrajectoryPt, JointTrajectoryPt, AxialSymmetricPt> Implementations;
00085
00086 TYPED_TEST_CASE(TrajectoryPtTest, Implementations);
00087
00088 TYPED_TEST(TrajectoryPtTest, construction)
00089 {
00090 EXPECT_FALSE(this->lhs_->getID().is_nil());
00091 EXPECT_FALSE(this->lhs_copy_->getID().is_nil());
00092 EXPECT_FALSE(this->lhs_clone_->getID().is_nil());
00093 EXPECT_FALSE(this->rhs_->getID().is_nil());
00094
00095
00096
00097
00098
00099
00100
00101
00102 EXPECT_NE(this->lhs_->getID(), this->rhs_->getID());
00103
00104
00105
00106 EXPECT_EQ(this->lhs_->getID(), this->lhs_copy_->getID());
00107
00108
00109
00110 EXPECT_NE(this->lhs_->getID(), this->lhs_clone_->getID());
00111
00112
00113
00114 EXPECT_EQ(this->lhs_->getID(), this->lhs_same_->getID());
00115
00116
00117 EXPECT_TRUE(equal(this->lhs_->getTiming(), this->lhs_copy_->getTiming()));
00118 EXPECT_TRUE(equal(this->lhs_->getTiming(), this->lhs_clone_->getTiming()));
00119 EXPECT_FALSE(equal(this->lhs_->getTiming(), this->rhs_->getTiming()));
00120 }