nec2++  1.7.0
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 #ifndef __nec_debug__
21 #define __nec_debug__
22 
23 #include <iostream>
24 #include <string>
25 #include <sstream>
26 
27 #ifdef NEC_ERROR_CHECK
28  #define DEBUG_TRACE(__x) {std::cout << __x << std::endl;}
29  #define ASSERT(__x) \
30  { if (false == (__x))\
31  { std::stringstream __ss; \
32  __ss << "assert in file " << __FILE__ << " at line " << __LINE__;\
33  std::string __s = __ss.str(); \
34  throw __s.c_str(); \
35  } \
36  }
37  #define ASSERT_EQUAL(__x, __y) ASSERT(fabs((__x) - (__y)) < 1e-15)
38 #else
39  #define DEBUG_TRACE(__x)
40  #define ASSERT(__x)
41  #define ASSERT_EQUAL(__x, __y)
42 #endif /* NEC_ERROR_CHECK */
43 
44 #endif /* __nec_debug__ */