macros.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 
25 #ifndef SRC_CORE_INCLUDE_CORBO_CORE_MACROS_H_
26 #define SRC_CORE_INCLUDE_CORBO_CORE_MACROS_H_
27 
28 namespace corbo {
29 
30 // Convert text to string
31 #define corbo_STRINGIZE_I(text) #text
32 #define corbo_STRINGIZE(text) corbo_STRINGIZE_I(text)
33 
34 // Concatenate text
35 #define corbo_CAT_I(a, b) a##b
36 #define corbo_CAT(a, b) corbo_CAT_I(a, b)
37 
38 // Extensions for GTEST
39 #define EXPECT_EQ_MATRIX(A, B, tol) \
40  { \
41  EXPECT_EQ((A).rows(), (B).rows()); \
42  EXPECT_EQ((A).cols(), (B).cols()); \
43  EXPECT_TRUE((A).isApprox(B, tol)) << corbo_STRINGIZE(A) ":\n" << A << "\n" << corbo_STRINGIZE(B) ":\n" << B << ". "; \
44  }
45 
46 #define EXPECT_NEQ_MATRIX(A, B, tol) \
47  { \
48  EXPECT_EQ((A).rows(), (B).rows()); \
49  EXPECT_EQ((A).cols(), (B).cols()); \
50  EXPECT_FALSE((A).isApprox(B, tol)) << corbo_STRINGIZE(A) ":\n" << A << "\n" << corbo_STRINGIZE(B) ":\n" << B << ". "; \
51  }
52 
53 #define EXPECT_ZERO_MATRIX(A, tol) \
54  EXPECT_TRUE(A.isZero(tol)) << corbo_STRINGIZE(A) ":\n" \
55  << A << "\n" \
56  << ". "
57 
58 // Static if for C++17
59 #if __cplusplus > 201402L
60 #define static_if \
61  if \
62  constexpr
63 #else
64 #define static_if if
65 #endif
66 
67 #if defined(__GNUC__)
68 #define corbo_DEPRECATED __attribute__((deprecated))
69 #define corbo_FORCE_INLINE __attribute__((always_inline))
70 #elif defined(_MSC_VER)
71 #define corbo_DEPRECATED
72 #define corbo_FORCE_INLINE __forceinline
73 #else
74 #define corbo_DEPRECATED
75 #define corbo_FORCE_INLINE inline
76 #endif
77 
78 } // namespace corbo
79 
80 #endif // SRC_CORE_INCLUDE_CORBO_CORE_MACROS_H_


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:07:00