Directory: | ./ |
---|---|
File: | tests/comparison-types.cc |
Date: | 2025-05-05 12:19:30 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 52 | 52 | 100.0% |
Branches: | 140 | 280 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2020, CNRS - Airbus SAS | ||
2 | // Authors: Florent Lamiraux | ||
3 | // | ||
4 | |||
5 | // Redistribution and use in source and binary forms, with or without | ||
6 | // modification, are permitted provided that the following conditions are | ||
7 | // met: | ||
8 | // | ||
9 | // 1. Redistributions of source code must retain the above copyright | ||
10 | // notice, this list of conditions and the following disclaimer. | ||
11 | // | ||
12 | // 2. Redistributions in binary form must reproduce the above copyright | ||
13 | // notice, this list of conditions and the following disclaimer in the | ||
14 | // documentation and/or other materials provided with the distribution. | ||
15 | // | ||
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
20 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
27 | // DAMAGE. | ||
28 | |||
29 | #include <hpp/constraints/affine-function.hh> | ||
30 | #include <hpp/constraints/implicit.hh> | ||
31 | #include <hpp/pinocchio/liegroup-space.hh> | ||
32 | |||
33 | #define BOOST_TEST_MODULE ComparisonTypes | ||
34 | #include <boost/test/included/unit_test.hpp> | ||
35 | |||
36 | using hpp::constraints::ComparisonType; | ||
37 | using hpp::constraints::ComparisonTypes_t; | ||
38 | using hpp::constraints::DifferentiableFunctionPtr_t; | ||
39 | using hpp::constraints::Equality; | ||
40 | using hpp::constraints::EqualToZero; | ||
41 | using hpp::constraints::Identity; | ||
42 | using hpp::constraints::Implicit; | ||
43 | using hpp::constraints::ImplicitPtr_t; | ||
44 | using hpp::constraints::Inferior; | ||
45 | using hpp::constraints::Superior; | ||
46 | using hpp::pinocchio::LiegroupSpace; | ||
47 | |||
48 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(operators) |
49 | // int main() | ||
50 | { | ||
51 | // [Inferior] | ||
52 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
2 | ComparisonTypes_t expected, actual(1, Inferior); |
53 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Inferior); |
54 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, actual); |
55 | // [Equality, EqualToZero] | ||
56 | 2 | expected.clear(); | |
57 | 2 | actual.clear(); | |
58 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Equality); |
59 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(EqualToZero); |
60 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | actual = ComparisonTypes_t(Equality << EqualToZero); |
61 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, actual); |
62 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, Equality << EqualToZero); |
63 | |||
64 | // [Equality, EqualToZero, Inferior] | ||
65 | 2 | expected.clear(); | |
66 | 2 | actual.clear(); | |
67 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Equality); |
68 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(EqualToZero); |
69 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Inferior); |
70 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | actual = (Equality << EqualToZero << Inferior); |
71 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, actual); |
72 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, Equality << EqualToZero << Inferior); |
73 | |||
74 | // [Equality, EqualToZero, 4 * Inferior] | ||
75 | 2 | expected.clear(); | |
76 | 2 | actual.clear(); | |
77 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Equality); |
78 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(EqualToZero); |
79 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Inferior); |
80 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Inferior); |
81 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Inferior); |
82 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Inferior); |
83 | |||
84 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
2 | actual = (Equality << EqualToZero << 4 * Inferior); |
85 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, actual); |
86 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, Equality << EqualToZero << 4 * Inferior); |
87 | // [EqualToZero, EqualToZero, EqualToZero, EqualToZero, EqualToZero, | ||
88 | // Equality, Equality, Equality] -> ConvexShapeContact | ||
89 | 2 | expected.clear(); | |
90 | 2 | actual.clear(); | |
91 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(EqualToZero); |
92 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(EqualToZero); |
93 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(EqualToZero); |
94 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(EqualToZero); |
95 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(EqualToZero); |
96 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Equality); |
97 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Equality); |
98 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | expected.push_back(Equality); |
99 | |||
100 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
4 | actual = (EqualToZero << EqualToZero << EqualToZero << EqualToZero |
101 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
2 | << EqualToZero << Equality << Equality << Equality); |
102 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, actual); |
103 | ImplicitPtr_t constraint(Implicit::create( | ||
104 |
3/6✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
4 | Identity::create(LiegroupSpace::Rn(8), "I8"), |
105 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
4 | EqualToZero << EqualToZero << EqualToZero << EqualToZero << EqualToZero |
106 |
4/8✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
|
12 | << Equality << Equality << Equality)); |
107 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, constraint->comparisonType()); |
108 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
6 | actual = ComparisonTypes_t(EqualToZero << EqualToZero << EqualToZero |
109 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
4 | << EqualToZero << EqualToZero |
110 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
4 | << Equality << Equality << Equality); |
111 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
|
2 | BOOST_CHECK_EQUAL(expected, actual); |
112 | 2 | } | |
113 |