GCC Code Coverage Report


Directory: ./
File: unittest/factory/control.cpp
Date: 2025-02-24 23:41:29
Exec Total Coverage
Lines: 35 42 83.3%
Branches: 12 27 44.4%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021, University of Edinburgh, University of Trento
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #include "control.hpp"
10
11 #include "crocoddyl/core/controls/poly-one.hpp"
12 #include "crocoddyl/core/controls/poly-two-rk.hpp"
13 #include "crocoddyl/core/controls/poly-zero.hpp"
14 #include "crocoddyl/core/utils/exception.hpp"
15
16 namespace crocoddyl {
17 namespace unittest {
18
19 const std::vector<ControlTypes::Type> ControlTypes::all(
20 ControlTypes::init_all());
21
22 303 std::ostream& operator<<(std::ostream& os, ControlTypes::Type type) {
23
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 switch (type) {
24 116 case ControlTypes::PolyZero:
25 116 os << "PolyZero";
26 116 break;
27 116 case ControlTypes::PolyOne:
28 116 os << "PolyOne";
29 116 break;
30 24 case ControlTypes::PolyTwoRK3:
31 24 os << "PolyTwoRK3";
32 24 break;
33 47 case ControlTypes::PolyTwoRK4:
34 47 os << "PolyTwoRK4";
35 47 break;
36 case ControlTypes::NbControlTypes:
37 os << "NbControlTypes";
38 break;
39 default:
40 break;
41 }
42 303 return os;
43 }
44
45 679 ControlFactory::ControlFactory() {}
46 679 ControlFactory::~ControlFactory() {}
47
48 std::shared_ptr<crocoddyl::ControlParametrizationModelAbstract>
49 725 ControlFactory::create(ControlTypes::Type control_type,
50 const std::size_t nu) const {
51 725 std::shared_ptr<crocoddyl::ControlParametrizationModelAbstract> control;
52
4/5
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 95 times.
✗ Branch 4 not taken.
725 switch (control_type) {
53 302 case ControlTypes::PolyZero:
54 control =
55
1/2
✓ Branch 1 taken 302 times.
✗ Branch 2 not taken.
302 std::make_shared<crocoddyl::ControlParametrizationModelPolyZero>(nu);
56 302 break;
57 256 case ControlTypes::PolyOne:
58 control =
59
1/2
✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
256 std::make_shared<crocoddyl::ControlParametrizationModelPolyOne>(nu);
60 256 break;
61 72 case ControlTypes::PolyTwoRK3:
62 control =
63 72 std::make_shared<crocoddyl::ControlParametrizationModelPolyTwoRK>(
64
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 nu, RKType::three);
65 72 break;
66 95 case ControlTypes::PolyTwoRK4:
67 control =
68 95 std::make_shared<crocoddyl::ControlParametrizationModelPolyTwoRK>(
69
1/2
✓ Branch 1 taken 95 times.
✗ Branch 2 not taken.
95 nu, RKType::four);
70 95 break;
71 default:
72 throw_pretty(__FILE__ ": Wrong ControlTypes::Type given");
73 break;
74 }
75 725 return control;
76 }
77
78 } // namespace unittest
79 } // namespace crocoddyl
80