libnxter  0.1
Debug.nxc
Go to the documentation of this file.
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  Debug.nxc
4  Copyright (C) 2008 Naba Kumar <naba@gnome.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
34 #ifndef __DEBUG_H_
35 #define __DEBUG_H_
36 
37 #ifdef ENABLE_DEBUG
38 
45 #define ASSERT(exp, mesg) \
46  if (!(exp)) \
47  { \
48  ClearScreen(); \
49  TextOut(0, LCD_LINE1, "Critical assertion failed:"); \
50  TextOut(0, LCD_LINE2, mesg); \
51  Wait(5000); \
52  StopAllTasks(); \
53  }
54 
60 #define WARNING(exp, mesg) \
61  if (!(exp)) \
62  { \
63  ClearScreen(); \
64  TextOut(0, LCD_LINE1, "Warning assertion failed:"); \
65  TextOut(0, LCD_LINE2, mesg); \
66  }
67 #else
68  #define ASSERT(x, mesg)
69  #define WARNING(x, mesg)
70 #endif
71 
72 #ifdef ENABLE_TEST
73 
80 #define TEST(exp, mesg) \
81  if (!(exp)) \
82  { \
83  ClearScreen(); \
84  TextOut(0, LCD_LINE1, "Test failed:"); \
85  TextOut(0, LCD_LINE2, mesg); \
86  Wait(5000); \
87  StopAllTasks(); \
88  }
89 #else
90  #define TEST(x, mesg)
91 #endif
92 
93 void TestDebug()
94 {
95  ASSERT(1==2, "1 is not equal to 2");
96  WARNING(1==2, "1 is not equal to 2");
97  TEST(1==2, "1 is not equal to 2");
98 }
99 
100 #endif
101