VSM C++ SDK
Vehicle Specific Modules SDK
Home
Related Pages
Namespaces
Classes
Files
Code examples
UgCS site
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
debug.h
Go to the documentation of this file.
1
// Copyright (c) 2018, Smart Projects Holdings Ltd
2
// All rights reserved.
3
// See LICENSE file for license details.
4
11
#ifndef _UGCS_VSM_DEBUG_H_
12
#define _UGCS_VSM_DEBUG_H_
13
14
#include <
ugcs/vsm/log.h
>
15
16
#include <stdexcept>
17
21
#ifdef UNITTEST
22
23
#define ASSERT_IMPL(cond_str) do { \
24
VSM_EXCEPTION(::ugcs::vsm::Debug_assert_exception, cond_str); \
25
} while (false)
26
27
#else
/* UNITTEST */
28
29
#define ASSERT_IMPL(cond_str) do { \
30
/* More convenient than exception since the back-trace will point to the \
31
* assert in the generated core dump. \
32
*/
\
33
abort(); \
34
} while (false)
35
36
#endif
/* UNITTEST */
37
38
#ifdef DEBUG
39
44
#define ASSERT(x) do { \
45
if (!(x)) { \
46
LOG_ERROR("Assert failed: '%s'", # x); \
47
if (std::uncaught_exception()) { \
48
LOG_ERROR("WARNING: uncaught exception active when assertion fired!"); \
49
} \
50
ASSERT_IMPL(# x); \
51
} \
52
} while (false)
53
58
#define VERIFY(x, expected) do { \
59
if ((x) != (expected)) { \
60
LOG_ERROR("Verification failed: '%s'", # x " == " # expected); \
61
ASSERT_IMPL(# x " == " # expected); \
62
} \
63
} while (false)
64
65
#else
/* DEBUG */
66
68
#define ASSERT(x)
69
71
#define VERIFY(x, expected) x
72
73
#endif
/* DEBUG */
74
75
#endif
/* _UGCS_VSM_DEBUG_H_ */
log.h
Logging functionality for VSM.
include
ugcs
vsm
debug.h
Generated on Fri Jan 31 2020 14:25:52 for VSM C++ SDK by
1.8.6