test-operations.cc 1.95 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (C) 2016 LAAS-CNRS
// Author: Anna Seppala 
//
// This file is part of the hpp-affordance.
//
// hpp-affordance is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// hpp-affordance is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with hpp-affordance.  If not, see <http://www.gnu.org/licenses/>.

#include <hpp/affordance/operations.hh>
#include <hpp/affordance/fwd.hh>

#define BOOST_TEST_MODULE test-operations
#include <boost/test/included/unit_test.hpp>

Steve Tonneau's avatar
Steve Tonneau committed
25
26
27
28
29
30
31
32
33
34
35
36
const double epsilon = 10e-6;

bool compDouble(const double a, const double b)
{
    return a-b < epsilon;
}

bool compVec(const fcl::Vec3f& a, const fcl::Vec3f& b)
{
    return (a-b).norm() < epsilon;
}

37
38
39
40
BOOST_AUTO_TEST_SUITE (test_affordance)

BOOST_AUTO_TEST_CASE (operations)
{
Steve Tonneau's avatar
Steve Tonneau committed
41
  hpp::affordance::SupportOperationPtr_t support (new hpp::affordance::SupportOperation(0.3));
42
43
44
45
46
47
48
49
  hpp::affordance::LeanOperationPtr_t lean (new hpp::affordance::LeanOperation(0.1));

  std::vector <hpp::affordance::OperationBasePtr_t> operations;
  operations.push_back(support);
  operations.push_back(lean);

  const fcl::Vec3f normal1(0, 0, 1);

Steve Tonneau's avatar
Steve Tonneau committed
50
    BOOST_CHECK_MESSAGE (compVec(support->zWorld_,normal1),
Akseppal's avatar
Akseppal committed
51
		"default value for zWorld should be " << normal1 << " but is " << support->zWorld_);
52

Steve Tonneau's avatar
Steve Tonneau committed
53
    BOOST_CHECK_MESSAGE (compDouble(lean->margin_,0.1),
54
55
56
57
58
59
		"margin should match the one given when creating operation");

	BOOST_CHECK_MESSAGE (operations.size () == 2, 
		"operation vector should have size 2 after adding support and lean");
}
BOOST_AUTO_TEST_SUITE_END ()