nec2++ 2.1.1
nec_debug.h
1/***************************************************************************
2 * Copyright (C) 2004-2005 by Tim Molteno *
3 * tim@molteno.net *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20#pragma once
21
22#include <iostream>
23#include <string>
24#include <sstream>
25
26#ifdef NEC_ERROR_CHECK
27 #define DEBUG_TRACE(__x) {std::cout << __x << std::endl;}
28 #define ASSERT(__x) \
29 { if (false == (__x))\
30 { std::ostringstream __ss; \
31 __ss << "assert in file " << __FILE__ << " at line " << __LINE__;\
32 throw __ss.str(); \
33 } \
34 }
35 #define ASSERT_EQUAL(__x, __y) ASSERT(fabs((__x) - (__y)) < 1e-15)
36#else
37 #define DEBUG_TRACE(__x)
38 #define ASSERT(__x)
39 #define ASSERT_EQUAL(__x, __y)
40#endif /* NEC_ERROR_CHECK */