GCC Code Coverage Report


Directory: ./
File: include/crocoddyl/core/utils/version.hpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 6 6 100.0%
Branches: 7 14 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019, LAAS-CNRS
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #ifndef CROCODDYL_CORE_UTILS_VERSION_HPP_
10 #define CROCODDYL_CORE_UTILS_VERSION_HPP_
11
12 #include <sstream>
13 #include <string>
14
15 #include "crocoddyl/config.hh"
16
17 namespace crocoddyl {
18
19 ///
20 /// \brief Returns the current version of Crocoddyl as a string using
21 /// the following standard:
22 /// CROCODDYL_MINOR_VERSION.CROCODDYL_MINOR_VERSION.CROCODDYL_PATCH_VERSION
23 ///
24 10 inline std::string printVersion(const std::string& delimiter = ".") {
25
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 std::ostringstream oss;
26
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 oss << CROCODDYL_MAJOR_VERSION << delimiter << CROCODDYL_MINOR_VERSION
27
3/6
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
10 << delimiter << CROCODDYL_PATCH_VERSION;
28
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 return oss.str();
29 10 }
30
31 ///
32 /// \brief Checks if the current version of Crocoddyl is at least the version
33 /// provided
34 /// by the input arguments.
35 ///
36 /// \param[in] major_version Major version to check.
37 /// \param[in] minor_version Minor version to check.
38 /// \param[in] patch_version Patch version to check.
39 ///
40 /// \returns true if the current version of Pinocchio is greater than the
41 /// version provided
42 /// by the input arguments.
43 ///
44 inline bool checkVersionAtLeast(int major_version, int minor_version,
45 int patch_version) {
46 return CROCODDYL_MAJOR_VERSION > major_version ||
47 (CROCODDYL_MAJOR_VERSION >= major_version &&
48 (CROCODDYL_MINOR_VERSION > minor_version ||
49 (CROCODDYL_MINOR_VERSION >= minor_version &&
50 CROCODDYL_PATCH_VERSION >= patch_version)));
51 }
52 } // namespace crocoddyl
53
54 #endif // CROCODDYL_CORE_UTILS_VERSION_HPP_
55