Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
expect.h
Go to the documentation of this file.
1#ifndef EXPECT_H
2#define EXPECT_H
3
4#include <iostream>
5
6namespace RoutingKit{
7
8extern bool expect_failed;
9
10namespace detail{
11 template<class T>
12 const T&handle_null_ptr(const T&t){return t;}
13 inline const char* handle_null_ptr(const char*p) { if(p) return p; else return "nullptr";}
14 inline const char* handle_null_ptr(const decltype(nullptr)) {return "nullptr";}
15
16}
17
18
19#define EXPECT2(c, c_msg, line) \
20 ((c) ? std::cerr : (expect_failed = true, std::cerr << c_msg <<" failed in line "<<line << std::endl))
21
22#define EXPECT(c) \
23 EXPECT2(c, #c, __LINE__)
24
25
26
27#define EXPECT_CMP2(x, op, y, x_msg, op_msg, y_msg, line) \
28 (((x) op (y)) ? std::cerr : (expect_failed = true, std::cerr << x_msg << ' ' <<op_msg << ' ' << y_msg << " failed in line "<<line <<"\n"<<x_msg<<" is "<<::RoutingKit::detail::handle_null_ptr(x)<<"\n"<<y_msg<<" is "<<::RoutingKit::detail::handle_null_ptr(y) << std::endl))
29
30#define EXPECT_CMP(x, op, y) \
31 EXPECT_CMP2(x, op, y, #x, #op, #y, __LINE__)
32
33
34
35
36}
37
38#endif
const T & handle_null_ptr(const T &t)
Definition expect.h:12
bool expect_failed
Definition expect.cpp:4