Main MRPT website > C++ reference for MRPT 1.9.9
xassert_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <mrpt/typemeta/xassert.h>
11 #include <gtest/gtest.h>
12 
13 constexpr int foo_i_below_10(unsigned i) { return MRPT_X_ASSERT(i < 10), 0; }
14 TEST(XAssert, build_time)
15 {
16  // Builds:
17  constexpr int x = foo_i_below_10(0);
18  (void)(x);
19 
20  // Does not build
21  // constexpr int y = foo_i_below_10(11);
22 
23  // runs:
24  foo_i_below_10(0);
25 
26  // throws:
27  EXPECT_THROW(foo_i_below_10(11), std::exception);
28 }
foo_i_below_10
constexpr int foo_i_below_10(unsigned i)
Definition: xassert_unittest.cpp:13
xassert.h
MRPT_X_ASSERT
#define MRPT_X_ASSERT(CHECK)
MRPT_X_ASSERT(): build error if condition is known not to work at compile time, throw an exception at...
Definition: xassert.h:27
void
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
TEST
TEST(XAssert, build_time)
Definition: xassert_unittest.cpp:14
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST