macros.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021 CNRS INRIA
3 //
4 
5 #include "pinocchio/macros.hpp"
6 
7 #include <boost/test/unit_test.hpp>
8 #include <boost/utility/binary.hpp>
9 
10 using namespace pinocchio;
11 
12 std::string expected_msg;
13 
14 bool check_exception_msg (const std::exception& exception)
15 {
16  BOOST_CHECK_EQUAL(expected_msg, exception.what());
17  return expected_msg == exception.what();
18 }
19 
20 BOOST_AUTO_TEST_SUITE ( BOOST_TEST_MODULE )
21 
22 void function_1(std::vector<int> v, size_t size)
23 {
25  //"size of input vector should be " << size)
26 }
27 void function_2(std::vector<int> v, size_t size)
28 {
29  PINOCCHIO_CHECK_ARGUMENT_SIZE(v.size(), size,
30  "custom message " << "with stream");
31 }
32 
33 BOOST_AUTO_TEST_CASE(test_check_arguments)
34 {
35  expected_msg = "wrong argument size: expected 2, got 3\n"
36  "hint: v.size() is different from size\n";
37  BOOST_CHECK_EXCEPTION(function_1(std::vector<int>(3), 2),
38  std::invalid_argument,
40  expected_msg = "wrong argument size: expected 2, got 3\n"
41  "hint: custom message with stream\n";
42  BOOST_CHECK_EXCEPTION(function_2(std::vector<int>(3), 2),
43  std::invalid_argument,
45 }
46 
47 BOOST_AUTO_TEST_SUITE_END()
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
std::size_t size(custom_string const &s)
bool check_exception_msg(const std::exception &exception)
Definition: macros.cpp:14
void function_2(std::vector< int > v, size_t size)
Definition: macros.cpp:27
BOOST_AUTO_TEST_CASE(test_check_arguments)
Definition: macros.cpp:33
#define PINOCCHIO_CHECK_ARGUMENT_SIZE(...)
Macro to check if the size of an element is equal to the expected size.
Definition: src/macros.hpp:147
void function_1(std::vector< int > v, size_t size)
Definition: macros.cpp:22
Main pinocchio namespace.
Definition: timings.cpp:30
std::string expected_msg
Definition: macros.cpp:12


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:04