GCC Code Coverage Report


Directory: ./
File: unittest/factory/control.cpp
Date: 2025-03-26 19:23:43
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
15 namespace crocoddyl {
16 namespace unittest {
17
18 const std::vector<ControlTypes::Type> ControlTypes::all(
19 ControlTypes::init_all());
20
21 303 std::ostream& operator<<(std::ostream& os, ControlTypes::Type type) {
22
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) {
23 116 case ControlTypes::PolyZero:
24 116 os << "PolyZero";
25 116 break;
26 116 case ControlTypes::PolyOne:
27 116 os << "PolyOne";
28 116 break;
29 24 case ControlTypes::PolyTwoRK3:
30 24 os << "PolyTwoRK3";
31 24 break;
32 47 case ControlTypes::PolyTwoRK4:
33 47 os << "PolyTwoRK4";
34 47 break;
35 case ControlTypes::NbControlTypes:
36 os << "NbControlTypes";
37 break;
38 default:
39 break;
40 }
41 303 return os;
42 }
43
44 679 ControlFactory::ControlFactory() {}
45 679 ControlFactory::~ControlFactory() {}
46
47 std::shared_ptr<crocoddyl::ControlParametrizationModelAbstract>
48 725 ControlFactory::create(ControlTypes::Type control_type,
49 const std::size_t nu) const {
50 725 std::shared_ptr<crocoddyl::ControlParametrizationModelAbstract> control;
51
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) {
52 302 case ControlTypes::PolyZero:
53 control =
54
1/2
✓ Branch 1 taken 302 times.
✗ Branch 2 not taken.
302 std::make_shared<crocoddyl::ControlParametrizationModelPolyZero>(nu);
55 302 break;
56 256 case ControlTypes::PolyOne:
57 control =
58
1/2
✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
256 std::make_shared<crocoddyl::ControlParametrizationModelPolyOne>(nu);
59 256 break;
60 72 case ControlTypes::PolyTwoRK3:
61 control =
62 72 std::make_shared<crocoddyl::ControlParametrizationModelPolyTwoRK>(
63
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 nu, RKType::three);
64 72 break;
65 95 case ControlTypes::PolyTwoRK4:
66 control =
67 95 std::make_shared<crocoddyl::ControlParametrizationModelPolyTwoRK>(
68
1/2
✓ Branch 1 taken 95 times.
✗ Branch 2 not taken.
95 nu, RKType::four);
69 95 break;
70 default:
71 throw_pretty(__FILE__ ": Wrong ControlTypes::Type given");
72 break;
73 }
74 725 return control;
75 }
76
77 } // namespace unittest
78 } // namespace crocoddyl
79