Line |
Branch |
Exec |
Source |
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 |
|
|
{ |
24 |
|
✗ |
PINOCCHIO_CHECK_ARGUMENT_SIZE(v.size(), size); |
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, "custom message " << "with stream"); |
30 |
|
|
} |
31 |
|
|
|
32 |
|
✗ |
BOOST_AUTO_TEST_CASE(test_check_arguments) |
33 |
|
|
{ |
34 |
|
|
expected_msg = "wrong argument size: expected 2, got 3\n" |
35 |
|
✗ |
"hint: v.size() is different from size\n"; |
36 |
|
✗ |
BOOST_CHECK_EXCEPTION( |
37 |
|
|
function_1(std::vector<int>(3), 2), std::invalid_argument, check_exception_msg); |
38 |
|
|
expected_msg = "wrong argument size: expected 2, got 3\n" |
39 |
|
✗ |
"hint: custom message with stream\n"; |
40 |
|
✗ |
BOOST_CHECK_EXCEPTION( |
41 |
|
|
function_2(std::vector<int>(3), 2), std::invalid_argument, check_exception_msg); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
BOOST_AUTO_TEST_SUITE_END() |
45 |
|
|
|