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 }
constexpr int foo_i_below_10(unsigned i)
#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
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLenum GLint x
Definition: glext.h:3538
TEST(XAssert, build_time)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020